I run a few web-hosting ubuntu VMs on a hyper-v server. So I'm not surprised about your issues here. The real issue is that the documentation is not really clear in many aspects and a lot of guides on the internet are dated.
E.g. I would not trust "ubuntu on hyperv" guides from before server 2019 (1809) was out. As for actual ubuntu versions, trash any guides for versions before 20.04LTS. I have/had successfully run VMs 20.04, 21.10, 22.04, 22.10 in various configurations.
Now the real answer here would be to check your kernel. Hyper-v capabilities highly rely on the kernel. If you install some lightweight non-suitable kernel not only your fstrim, but some other virtualisation things like e.g. dynamic RAM resize may stop working.
As a sidenote -- I once had a debian12 (preview) VM on hyper-v where
dynamic RAM could be increased, but never decreased :D Which would mean it was always increasing upto defined limit. This was caused by incompatible kernel.
So in short my recommendation is to install HWE-EDGE kernel. My 22.04 VM currently runs on 5.19.0-41-generic, which is the most updated kernel from the following package:
linux-generic-hwe-22.04-edge/jammy-updates,jammy-security,now
5.19.0.41.42~22.04.14 amd64 [installed]
of course you can also run on just HWE, but I have never had any issues running edge variant on 20.04 or 22.04.
Another option, if you want maybe a smaller more optimized kernel, is to run linux-azure kernels. E.g. on the dated 20.04 machine I currently run:
linux-azure-edge/focal-updates,focal-security,now 5.15.0.1038.45~20.04.28 amd64 [installed]