  A measurement of $W^\pm$ boson production in lead-lead collisions at
$\sqrt{s_\mathrm{NN}} = 5.02$ TeV is reported using data recorded by the ATLAS
experiment at the LHC in 2015, corresponding to a total integrated luminosity
of $0.49\;\mathrm{nb^{-1}}$. The $W^\pm$ bosons are reconstructed in the
electron or muon leptonic decay channels. Production yields of leptonically
decaying $W^\pm$ bosons, normalised by the total number of minimum-bias events
and the nuclear thickness function, are measured within a fiducial region
defined by the detector acceptance and the main kinematic requirements. These
normalised yields are measured separately for $W^+$ and $W^-$ bosons, and are
presented as a function of the absolute value of pseudorapidity of the charged
lepton and of the collision centrality. The lepton charge asymmetry is also
measured as a function of the absolute value of lepton pseudorapidity. In
addition, nuclear modification factors are calculated using the $W^\pm$ boson
production cross-sections measured in $pp$ collisions. The results are compared
with predictions based on next-to-leading-order calculations with CT14 parton
distribution functions as well as with predictions obtained with the EPPS16 and
nCTEQ15 nuclear parton distribution functions. No dependence of normalised
production yields on centrality and a good agreement with predictions are
observed for mid-central and central collisions. For peripheral collisions, the
data agree with predictions within 1.7 (0.9) standard deviations for $W^-$
($W^+$) bosons.
