Bound states of charm and anticharm quarks, known as charmonia, have a rich spectroscopic structure that can be used to probe the dynamics of hadron production in high-energy hadron collisions. Here, the cross section ratio of excited (ψ(2S)) and ground state (J/ψ) vector mesons is measured as a function of the charged-particle multiplicity in proton-lead (pPb) collisions at a center-of-mass (CM) energy per nucleon pair of 8.16 TeV. The data corresponding to an integrated luminosity of 175 nb−1 were collected using the CMS detector. The ratio is measured separately for prompt and nonprompt charmonia in the transverse momentum range 6.5<pT<30 GeV and in four rapidity ranges spanning −2.865<yCM<1.935. For the first time, a statistically significant multiplicity dependence of the prompt cross section ratio is observed in proton-nucleus collisions. There is no clear rapidity dependence in the ratio. The prompt measurements are compared with a theoretical model which includes interactions with nearby particles during the evolution of the system. These results provide additional constraints on hadronization models of heavy quarks in nuclear collisions.