This does need support in the guest VM, but I've only ever had issues with really old Linux distros.
Microsoft implemented a Firecracker style microVM (they call it "Krypton") for Hyper-V, which is used for WSL2, Edge Application Guard (run Edge in a VM), and Windows Sandbox. There aren't any real good docs on how to create one yourself using the Host Compute Service.
https://learn.microsoft.com/en-us/windows/security/threat-pr...
Also WSL2, if I recall correctly, has a relatively minimal base OS with a custom init binary.
I would say if you’re looking to use Host Compute Service, your best option would be to look at the way https://github.com/microsoft/hcsshim initializes containers.
Things like dynamic memory allocation and release aren't some kind of black magic, but are something that is actually directly communicated by the guest VM.