I’ve used cgroups on “regular” VM’s to do this - I’m not sure if there are any weird things that crop up if you do that in a Fly VM (the weirdest part is likely trying to get the config to take effect when the VM boots up - perhaps via ENTRYPOINT script).
How to install them depends on the base container used. (cgroups, kind)
(I’m not really the expert on this topic, so take this with a grain of salt).
An alternative take I think I like better is to setup some swap when the VM boots via ENTRYPOINT script. Searching this forum can get you some pointers on doing that, such as this : Swap memory - #8 by rubys