Make the conditions that check for muted state sub-events to the click event. Then at least you set the mute state immediately, rather than playing the audio at full volume, then waiting for the next run of the events a few milliseconds later to set the muted state. (Remember triggers fire outside of the normal top-to-bottom event flow.)
Even then some implementations may play a short click, since you still play the audio at full volume, then mute it a moment later, and audio may start playing between the two actions running. If you intend to have the audio muted, don't play it at 0dB - play it at -99dB to begin with.