Mail.app flags are accessible via AppleScript in the flag index property of the message object. The index starts at 0 (-1 meaning “no flag”), counting up in the order in which flags are listed in the Mail menu. You can either create a pure AppleScript:
tell application "Mail"
set selectedMessages to (selected messages of front message viewer)
if (count of selectedMessages) is greater than 0 then
repeat with theMessage in selectedMessages
set flag index of theMessage to <index>
end repeat
end if
end tell
and assign it a hotkey through a launcher application like FastScripts, or embed it into a system service, by creating a Service Automator workflow set up to:
- take no input (!)
- in Mail.app
with the first item a “Get Selected Messages” action, followed by a “Run AppleScript” action with the following code:
on run {input, parameters}
set selectedMessages to input
tell application "Mail"
if (count of selectedMessages) is greater than 0 then
repeat with theMessage in selectedMessages
set flag index of theMessage to <index>
end repeat
end if
end tell
return input
end run
You can then assign a hotkey to your newly created service in the System Preferences, Keyboard settings:

ADDENDUM: if you prefer a pure GUI solution, you can also use MailActOn by Indev Software. Using MAO, you can setup a MailActOn rule (in Mail’s Rules setting panel, which MAO extends) to assign the flag. If you give that rule a unique MAO trigger letter and make sure the “Control+ActOn key applies rule” setting int the MAO preferences is checked, you can assign the flag to any selected mail with Ctrl+<trigger letter>:
