Studies of the fragmentation of jets into charged particles in heavy-ion collisions can provide information about the mechanism of jet quenching by the hot and dense QCD matter created in such collisions, the quark-gluon plasma. This paper presents a measurement of the angular distribution of charged particles around the jet axis in $\sqrt{{s}_{NN}}=5.02$ TeV $\mathrm{Pb}+\mathrm{Pb}$ and pp collisions, using the ATLAS detector at the LHC. The $\mathrm{Pb}+\mathrm{Pb}$ and $pp$ data sets have integrated luminosities of $0.49\phantom{\rule{0.16em}{0ex}}{\mathrm{nb}}^{\ensuremath{-}1}$ and $25\phantom{\rule{0.16em}{0ex}}{\mathrm{pb}}^{\ensuremath{-}1}$, respectively. The measurement is performed for jets reconstructed with the anti-${k}_{t}$ algorithm with radius parameter $R=0.4$ and is extended to an angular distance of $r=0.8$ from the jet axis. Results are presented as a function of $\mathrm{Pb}+\mathrm{Pb}$ collision centrality and distance from the jet axis for charged particles with transverse momenta in the 1- to 63-GeV range, matched to jets with transverse momenta in the 126- to 316-GeV range and an absolute value of jet rapidity of less than 1.7. Modifications to the measured distributions are quantified by taking a ratio to the measurements in $pp$ collisions. Yields of charged particles with transverse momenta below 4 GeV are observed to be increasingly enhanced as a function of angular distance from the jet axis, reaching a maximum at $r=0.6$. Charged particles with transverse momenta above 4 GeV have an enhanced yield in $\mathrm{Pb}+\mathrm{Pb}$ collisions in the jet core for angular distances up to $r=0.05$ from the jet axis, with a suppression at larger distances.