You just need to convert them to a surrogate pair, see https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF.
Edit: Some time ago I tricked some z-machine interpreters to print characters outside the BMP, this may be of some use as a test case: Z-Machine 1.2 Proposal (again) - #30 by borg323