  A search for heavy right-handed Majorana or Dirac neutrinos $N_{\mathrm{R}}$
and heavy right-handed gauge bosons $W_{\mathrm{R}}$ is performed in events
with energetic electrons or muons, with the same or opposite electric charge,
and energetic jets. The search is carried out separately for topologies of
clearly separated final-state products (``resolved'' channel) and topologies
with boosted final states with hadronic and/or leptonic products partially
overlapping and reconstructed as a large-radius jet (``boosted'' channel). The
events are selected from $pp$ collision data at the LHC with an integrated
luminosity of 139 fb$^{-1}$ collected by the ATLAS detector at $\sqrt{s}$ = 13
TeV. No significant deviations from the Standard Model predictions are
observed. The results are interpreted within the theoretical framework of a
left-right symmetric model, and lower limits are set on masses in the heavy
right-handed $W_{\mathrm{R}}$ boson and $N_{\mathrm{R}}$ plane. The excluded
region extends to about $m(W_{\mathrm{R}}) = 6.4$ TeV for both Majorana and
Dirac $N_{\mathrm{R}}$ neutrinos at $m(N_{\mathrm{R}})<1$ TeV. $N_{\mathrm{R}}$
with masses of less than 3.5 (3.6) TeV are excluded in the electron (muon)
channel at $m(W_{\mathrm{R}})=4.8$ TeV for the Majorana neutrinos, and limits
of $m(N_{\mathrm{R}})$ up to 3.6 TeV for $m(W_{\mathrm{R}}) = 5.2$ (5.0) TeV in
the electron (muon) channel are set for the Dirac neutrinos. These constitute
the most stringent exclusion limits to date for the model considered.
