You'd likely need to have the kernel be able to switch "keymaps" at anytime (and this is likely to be privileged and need to be done by root).
I know there was a way to load different keyboard layouts, but the problem with those mechanisms is they often cannot remap modifier keys, of which capslock is a special case of.
I know there was a way to load different keyboard layouts, but the problem with those mechanisms is they often cannot remap modifier keys, of which capslock is a special case of.