The production of J/ψ mesons in jets is studied in the forward region of proton-proton collisions using data collected with the LHCb detector at a center-of-mass energy of 13 TeV. The fraction of the jet transverse momentum carried by the J/ψ meson, z(J/ψ)≡pT(J/ψ)/pT(jet), is measured using jets with pT(jet)>20 GeV in the pseudorapidity range 2.5<η(jet)<4.0. The observed z(J/ψ) distribution for J/ψ mesons produced in b-hadron decays is consistent with expectations. However, the results for prompt J/ψ production do not agree with predictions based on fixed-order nonrelativistic QCD. This is the first measurement of the pT fraction carried by prompt J/ψ mesons in jets at any experiment.