  A search for heavy pseudo-scalar ($A$) and scalar ($H$) Higgs bosons decaying
into a top-quark pair ($t\bar{t}$) has been performed with 140 fb$^{-1}$ of
proton-proton collision data collected by the ATLAS experiment at the Large
Hadron Collider at a centre-of-mass energy of $\sqrt{s}=13$ TeV. Interference
effects between the signal process and Standard Model (SM) $t\bar{t}$
production are taken into account. Final states with exactly one or exactly two
electrons or muons are considered. No significant deviation from the SM
prediction is observed. The results of the search are interpreted in the
context of a two-Higgs-doublet model (2HDM) of type II in the alignment limit
with mass-degenerate pseudo-scalar and scalar Higgs bosons ($m_A = m_H$) and
the hMSSM parameterisation of the minimal supersymmetric extension of the
Standard Model. Ratios of the two vacuum expectation values, $\tan\beta$,
smaller than 3.49 (3.16) are excluded at 95% confidence level for $m_A = m_H =
400$ GeV in the 2HDM (hMSSM). Masses up to 1240 GeV are excluded for the lowest
tested $\tan\beta$ value of 0.4 in the 2HDM. In the hMSSM, masses up to 950 GeV
are excluded for $\tan\beta=1.0$. In addition, generic exclusion limits are
derived separately for single scalar and pseudo-scalar states for different
choices of their mass and total width.
