As far as I know it would be hard to do it outside of the boot firmware's own compatibility options (which most systems currently have AFAIK, but is probably on the way out). Whilst the old BIOS starts external code in Real Mode, with UEFI it sets the CPU into the operating mode. This means with most systems you'll be in 64 bit / Long Mode, and you can't leave that once entered.
You could have fun with hypervisors etc., but I guess we're thinking bare metal here?