From the Super Mario Wiki
To use it, the player must press and hold the button to make the Yoshi start sniffing on the ground. Yoshi can move while Sniff-Sniffing, but he does so more slowly than normally, attempting to detect something valuable to him in the ground. When the Yoshi gets closer to something special, he starts to sniff faster. Getting close to a secret causes a ! icon to pop up above the Yoshi's head, indicating that the secret is nearby. When the Yoshi is on the secret spot on the ground, he gets excited and signals the player by yelping and waving his arms. To retrieve the secret, the player must then make Yoshi Ground Pound the very spot where the hidden treasure lies.