  A search for heavy neutral leptons (HNLs) of Majorana or Dirac type using
proton-proton collision data at $\sqrt{s}$ = 13 TeV is presented. The data were
collected by the CMS experiment at the CERN LHC and correspond to an integrated
luminosity of 138 fb$^{-1}$. Events with three charged leptons (electrons,
muons, and hadronically decaying tau leptons) are selected, corresponding to
HNL production in association with a charged lepton and decay of the HNL to two
charged leptons and a standard model (SM) neutrino. The search is performed for
HNL masses between 10 GeV and 1.5 TeV. No evidence for an HNL signal is
observed in data. Upper limits at 95% confidence level are found for the
squared coupling strength of the HNL to SM neutrinos, considering exclusive
coupling of the HNL to a single SM neutrino generation, for both Majorana and
Dirac HNLs. The limits exceed previously achieved experimental constraints for
a wide range of HNL masses, and the limits on tau neutrino coupling scenarios
with HNL masses above the W boson mass are presented for the first time.
