You could make use of e.g. Tasker -- an automation tool which can react on different situations and handle a lot of things (basically, sometimes I think 80% of questions like "How can I...with Android?" could be answered by "Use Tasker!". Though it doesn't come "cheap", on the developers website you can get a 7-day trial to check first. It's worth every cent of its 5 bucks!).
So with tasker, you do simple math:
condition + task = profile
For your case, it's probably something like...
- Conditions: (they are always connected by AND with Tasker)
- "headphones plugged"
- "audio -> mic mute"
- optionally: "keyguard off"
- optionally: "display timeout 0" (as it is connected to a power source, so you can continually see what's displayed)
- most likely: "start app -> [music-app]".
Save & go. Now, when you dock your SGS2 and plug in the 3.5mm cord, mic should be muted -- and additionally some other nice actions executed.