This works for me as well—thanks for sharing!
To future readers:
I am also using an RPi5 with Ubuntu 24, and my local machine is running Ubuntu 22. Both sides have NoMachine version 8.16.1.
When adding video=HDMI-A-1:1920x1080M@60D vc4.force_hotplug=1 to /boot/firmware/cmdline.txt, make sure it remains on the same line as the original content. Do not press Enter; instead, keep everything space-separated on a single line. Otherwise, this will not work.