How to mute the microphone on Key-Down and unmute it on Key-Up?
First, the AppleScript that inspects the key state and handles the mic enabling and muting:

if (modKeyDowntest()) then
  tell application "System Events" to set volume input volume 100
  repeat while modKeyDowntest()
  end repeat
  tell application "System Events" to set volume input volume 0
end if

on modKeyDowntest()
  set modKeyDown to do shell script "~/opt/checkModifierKeys shift"
  set modKeyDown to modKeyDown as integer
  set modKeyDown to modKeyDown as boolean
end modKeyDowntest


Note, that


the script depends on the checkModifierKeys command line app (and it's path).
inspects the state of shift instead of caps lock (other possibilities are cmd, option, control and caps lock - caps lock, however, means the status of caps lock, not the key state!)


In the second step we bind the script to a key shortcut. There are many applications that can do this (some listed in an answer in SuperUser) or as an Automator service. (C&amp;P from Lri's answer...)


  One more option is to save the script as an Automator service:
  
  
  Open Automator and choose the Service template.
  Utilities — Run Shell Script / Run AppleScript.
  Service receives [no input] in [any application].
  Add the script to the text area and save.
  Assign a shortcut in System Preferences — Keyboard — Keyboard Shortcuts — Services.
  


So, I assigned opt+shift+M to the script above and it enables the mic, keeping it unmuted as long as I hold shift. The mic is muted again when I release shift.