Take a look at: https://learn.microsoft.com/en-us/powershell/module/hyper-v/optimize-vhd?view=windowsserver2022-ps
Also, take a look at the FSShrinkDisk script: https://github.com/FSLogix/Invoke-FslShrinkDisk (make sure you run this on a backup first). Used to shrink FSLogix VHDs, that are Dynamically expanding. I haven't tested this personally but could be an option.