  This Letter presents the first measurements of the groomed jet radius
$R_\mathrm{g}$ and the jet girth $g$ in events with an isolated photon
recoiling against a jet in lead-lead (PbPb) and proton-proton (pp) collisions
at the LHC at a nucleon-nucleon center-of-mass energy of 5.02 TeV. The
observables $R_\mathrm{g}$ and $g$ provide a quantitative measure of how narrow
or broad a jet is. The analysis uses PbPb and pp data samples with integrated
luminosities of 1.7 nb$^{-1}$ and 301 pb$^{-1}$, respectively, collected with
the CMS experiment in 2018 and 2017. Events are required to have a photon with
transverse momentum $p_\mathrm{T}^\gamma$ 100 GeV and at least one jet
back-to-back in azimuth with respect to the photon and with transverse momentum
$p_\mathrm{T}^\text{jet}$ such that
$p_\mathrm{T}^\text{jet}/p_\mathrm{T}^\gamma$ $>$ 0.4. The measured
$R_\mathrm{g}$ and $g$ distributions are unfolded to the particle level, which
facilitates the comparison between the PbPb and pp results and with theoretical
predictions. It is found that jets with
$p_\mathrm{T}^\text{jet}/p_\mathrm{T}^\gamma$ $>$ 0.8, i.e., those that closely
balance the photon $p_\mathrm{T}^\gamma$, are narrower in PbPb than in pp
collisions. Relaxing the selection to include jets with
$p_\mathrm{T}^\text{jet}/p_\mathrm{T}^\gamma$ $>$ 0.4 reduces the narrowing of
the angular structure of jets in PbPb relative to the pp reference. This shows
that selection bias effects associated with jet energy loss play an important
role in the interpretation of jet substructure measurements.
