In the Ecruteak Gym (5th Gym, Morty – Ghost type) in HeartGold/SoulSilver, there is no ice puzzle. The gym is a darkness/maze with invisible trainers revealed by defeating them.
You may be confusing it with:
To melt ice in Pokémon games: Use Fire-type moves (Ember, Flamethrower, Fire Blast) or Fire Pledge in specific contexts (e.g., X/Y Frost Cavern). No “Heat Wave” field move exists.
For Mahogany Gym: Just solve the slide puzzle (path: Up, Left, Up, Right, Up, Left, Down, Left, Up, Right).