J/ψ production as a function of charged-particle pseudorapidity density in p–Pb collisions at √sNN = 5.02 TeV