Jets containing a prompt J/psi meson are studied in lead-lead collisions at a nucleon-nucleon center-of mass energy of 5.02 TeV, using the CMS detector at the LHC. Jets are selected to be in the transverse momentum range of 30 <= pT <= 40 GeV. The J/psi yield in these jets is evaluated as a function of the jet fragmentation variable z, the ratio of the J/psi T-p to the jet p(T). The nuclear modification factor, R-AA, is then derived by comparing the yield in lead-lead collisions to the corresponding expectation based on proton-proton data, at the same nucleon-nucleon center-of-mass energy. The suppression of the J/psi yield shows a dependence on z, indicating that the interaction of the J/psi with the quark-gluon plasma formed in heavy ion collisions depends on the fragmentation that gives rise to the J/psi meson. (C) 2021 The Author(s). Published by Elsevier B.V. This is an open access article under the CC BY license (http://creativecommons.org/licenses/by/4.0/). Funded by SCOAP3.