Measurements of differential cross sections for $J/\ensuremath{\psi}$ production in $p+\mathrm{Pb}$ collisions at $\sqrt{{s}_{NN}}=5.02$ TeV at the CERN Large Hadron Collider with the ATLAS detector are presented. The data set used corresponds to an integrated luminosity of $28.1 {\mathrm{nb}}^{\ensuremath{-}1}$. The $J/\ensuremath{\psi}$ mesons are reconstructed in the dimuon decay channel over the transverse momentum range $8<{p}_{\mathrm{T}}<30\phantom{\rule{4.pt}{0ex}}\text{GeV}$ and over the center-of-mass rapidity range $\ensuremath{-}2.87<{y}^{*}<1.94$. Prompt $J/\ensuremath{\psi}$ are separated from $J/\ensuremath{\psi}$ resulting from $b$-hadron decays through an analysis of the distance between the $J/\ensuremath{\psi}$ decay vertex and the event primary vertex. The differential cross section for production of nonprompt $J/\ensuremath{\psi}$ is compared to a FONLL calculation that does not include nuclear effects. Forward-backward production ratios are presented and compared to theoretical predictions. These results complement previously published results by covering a region of higher transverse momentum and more central rapidity. They thus constrain the kinematic dependence of nuclear modifications of charmonium and $b$-quark production in $p+\mathrm{Pb}$ collisions.