Search for charged Higgs bosons in the $\mathrm{H}^{\pm} \to \tau^{\pm}\nu_\tau$ decay channel in proton-proton collisions at $\sqrt{s} = $ 13 TeV