Measurements of the inclusive J/\(\psi\) yield as a function of charged-particle pseudorapidity density \(\rm{d}N_\rm{ch}/\rm{d}\eta\) in pp collisions at \(\sqrt{s}\) = 13 TeV with ALICE at the LHC are reported. The J/\(\psi\) meson yield is measured at midrapidity (\(|y|<0.9\)) in the dielectron channel, for events selected based on the charged-particle multiplicity at midrapidity (\(|\eta|<1\)) and at forward rapidity (\(-3.7<\eta<-1.7\) and \(2.8<\eta<5.1\)); both observables are normalized to their corresponding averages in minimum bias events. The increase of the normalized J/\(\psi\) yield with normalized \(\rm{d}N/\rm{d}\eta\) is significantly stronger than linear and dependent on the transverse momentum. The data are compared to theoretical predictions, which describe the observed trends well, albeit not always quantitatively.