Ocarina of Time
If Link speaks with Bonooru in Lake Hylia as a child, he will boast that he can remember any song. Link can then play whatever what he wants the Scarecrow's Song to sound like, and Bonooru will keep it memorized. It he wants to change it, all he needs to do is take out his ocarina again and play a new song.
Once Link goes seven years into the future using the Master Sword, he can return to Lake Hylia to talk to Bonooru again. If Link can play the same song from before, Bonooru will praise him and mention that Pierre is traveling around. He explains that he can play that song to summon Pierre.
In Majora's Mask, Link must play the Scarecrow's Song for the Scarecrow found in the Astral Observatory. He will promise to appear if the song is played. Similar to in Ocarina of Time, Link can use the Hookshot to get to this Scarecrow to find secrets. However, if Link plays the Song of Time, he will have to return to the Scarecrow and speak with him once more or the song will have no effect.