  A search for a Higgs boson decaying into a pair of electrons or muons and a
photon is described. Higgs boson decays to a Z boson and a photon (H $\to$
Z$\gamma\to\ell\ell\gamma$, $\ell =$ e or $\mu$), or to two photons, one of
which has an internal conversion into a muon pair (H
$\to\gamma^{*}\gamma\to\mu\mu\gamma$) were considered. The analysis is
performed using a data set recorded by the CMS experiment at the LHC from
proton-proton collisions at a center-of-mass energy of 13 TeV, corresponding to
an integrated luminosity of 35.9 fb$^{-1}$. No significant excess above the
background prediction has been found. Limits are set on the cross section for a
standard model Higgs boson decaying to opposite-sign electron or muon pairs and
a photon. The observed limits on cross section times the corresponding
branching fractions vary between 1.4 and 4.0 (6.1 and 11.4) times the standard
model cross section for H $\to\gamma^{*}\gamma\to\mu\mu\gamma$ (H $\to$
Z$\gamma\to\ell\ell\gamma$) in the 120-130 GeV mass range of the
$\ell\ell\gamma$ system. The H $\to\gamma^*\gamma\to\mu\mu\gamma$ and H $\to$
Z$\gamma\to\ell\ell\gamma$ analyses are combined for $m_\mathrm{H} =$ 125 GeV,
obtaining an observed (expected) 95% confidence level upper limit of 3.9 (2.0)
times the standard model cross section.
