This is similar to what most web browsers do nowadays, indicating when audio is being played with an option to mute it.
When an application has an audio stream and it is actually playing something ("not corked"), after a delay of 2 seconds (to avoid flashing briefly) an audio icon is displayed which disappears again once audio stops playing. The context menu always offers the "Mute" option whenever there's an audio stream provided by the application, so you can still unmute even after playback has stopped. Also, the "muted" icon will be shown whilst the application is muted, regardless of whether sound is actually being played.
An application is marked as "Muted" when all associated streams are muted, and toggling mute will (un)mute all of them. Since PulseAudio doesn't know windows, when an application has multiple windows, all of them will be flagged as playing audio; the same issue we already have with Unity Launcher API.