From the Super Mario Wiki
The Mad Piano is a piano appearing in Super Mario 64 and Super Mario 64 DS. It looks normal at first, but when Luigi, Wario or Mario goes near the instrument, it begins to open and close its lid, revealing sharp teeth. The Mad Piano then proceeds to chase and attack the trespasser (while making the sounds that sound like someone hitting its keys) until they have left the room where the piano lies. The Mad Piano only appears in Big Boo's Haunt. A Red Coin can be found behind it.
It is impossible to defeat this enemy; it can only be avoided.
Names in Other Languages
In Kirby Triple Deluxe, a ghost possesses a piano that when possessed looks like the mad piano. It even sounds like it and attacks similarly.