I once had a cassette that was so clogged up with hardened chain wax that the chain would skip on the two smallest cogs. There was so much buildup between the 11t and 13t that the chain wouldn't seat fully and kept jumping out, causing a clicking sound and slippage. The wax was so hard that I had to chip it out with a small allen key, but after that it was fine.
So maybe if the cassette is super dirty, it's either interfering with chain engagement, or is somehow causing the chain to push up against the ramps for the next larger cog and making noise?