I have a selfhost tool that I use to mute all audio outputs programmatically.

Pseudocode:

IMMDeviceEnumerator::EnumAudioEndpoints
for each device:
    IMMDevice::Activate(IAudioEndpointVolume)
    IAudioEndpointVolume::SetMute(TRUE)

Source and binaries attached.