For vim purposes, I'd like to remap CapsLock to CTRL when used in combination with other keys and ESC when used in isolation.
None of the existing solutions give both functionality - only one or the other.
Step by step instructions:
Try out KeyRemap4Macbook, specifically the part called PCKeyboardHack. A year or so ago I was able to set it up so that holding down Caps Lock worked like Ctrl, but just tapping it brought up Exposé; so what you're asking should be possible.
Configuring KR4M, although it has a GUI, can be a little tricky because of the bewildering variety of options. I think you can probably scroll through the options and just look for ones under "PCKeyboardHack."
Note: I saw someone on IRC say they were unable to get this to work with the Mountain Lion preview; I don't have Lion yet to test out if it works there, but I don't see anything online about it not working (except for this possibly-unrelated bug).