  Recent work [B. Fore and S. Reddy, Phys. Rev. C 101 035809 (2020)] has shown
that the population of thermal pions could modify the equation of state and
transport properties of hot and dense neutron-rich matter and introduce new
reaction pathways to change the proton fraction. In this article we study their
impact on the bulk viscosity of dense matter, focusing on the neutrino-trapped
regime that would be realized in neutron star mergers and supernovae. We find
that the presence of a thermal population of pions alters the bulk viscosity by
modifying the EoS (via the susceptibilities) and by providing new reaction
pathways to achieve beta-equilibrium. In neutron star merger conditions, the
bulk viscosity in neutrino-trapped $npe\mu$ matter (without pions) has its peak
at temperatures of at most a couple MeV and is quite small at temperatures of
tens of MeV. We find that thermal pions enhance the low-temperature peak of the
bulk viscosity by a factor of a few and shift it to slightly lower
temperatures. At higher temperatures, where the pion abundance is large but the
bulk viscosity is traditionally small, pions can increase the bulk viscosity by
an order of magnitude or more, although it is still orders of magnitude smaller
than its peak value.
