I found using noise cancelling ear plugs helps a ton.

I have used them for many years, for sleeping or commuting in my public transport years.

I use them for sleeping too, just discovered them recently. Haven't had a chance to use them at a gym because there aren't any women only ones in my area unfortunately. Now thinking about it, I wonder if the sweat would make them more difficult to use.

The ones I use are just rubber, so I doubt sweat would cause a problem there.