The Hubble Space Telescope UV Legacy Survey of Galactic globular clusters – XXI. Binaries among multiple stellar populations