The production of prompt $\Lambda^+_\mathrm{c}$ baryons is measured via the exclusive decay channel $\Lambda^+_\mathrm{c}$$\to$ pK$^-\pi^+$ at a center-of-mass energy per nucleon pair of 5.02 TeV, using proton-proton (pp) and lead-lead (PbPb) collision data collected by the CMS experiment at the CERN LHC. The pp and PbPb data were obtained in 2017 and 2018 with integrated luminosities of 252 and 0.607 nb$^{-1}$, respectively. The measurements are performed within the $\Lambda^+_\mathrm{c}$ rapidity interval $\vert y \vert$$\lt$ 1 with transverse momentum ($p_\mathrm{T}$) ranges of 3-30 and 6-40 GeV/$c$ for pp and PbPb collisions, respectively. Compared to the yields in pp collisions scaled by the expected number of nucleon-nucleon interactions, the observed yields of $\Lambda^+_\mathrm{c}$ with $p_\mathrm{T}$$\gt$ 10 GeV/$c$ are strongly suppressed in PbPb collisions. The level of suppression depends significantly on the collision centrality. The $\Lambda^+_\mathrm{c}$ / D$^0$ production ratio is similar in PbPb and pp collisions at $p_\mathrm{T}$$\gt$ 10 GeV/$c$, suggesting that the coalescence process does not play a dominant role in prompt $\Lambda^+_\mathrm{c}$ baryon production at higher $p_\mathrm{T}$.