Search for rare decays of \(\mathrm {Z}\) and Higgs bosons to \({\mathrm {J}/\psi } \) and a photon in proton-proton collisions at \(\sqrt{s}\) = 13\(\,\text {TeV}\)