The episode you're thinking of is likely "The Last Resort" (also known as "Amy on the Beach"). It's a memorable one, especially given Sonic the Hedgehog's famous fear of water.
It's hard to believe the world's most iconic blue hedgehog is terrified of the water, but that's part of his charm. As Sally teases him, Sonic trades quips about being a hero versus a genie, delivering some classic banter. And notably, despite relying on his legs for speed, Sonic genuinely can't swim without some form of assistance—a fun bit of trivia for fans of the series.