I'm assuming an example like this:

Holy shield has a 10 sec cooldown.
If you press Holy Shield when it's on cooldown, you get an annoying "whoosh" sound per keypress
If it's not on cooldown, you get a nice little shield-like sound.

I believe the OP is asking for a way to press Holy Shield if and only if it is not on cooldown, and to basically /stopmacro when it is on cooldown.

If that is the case, the answer is no. The only thing you can do is turn off you in-game sounds. It's really annoying, I know.