I use an app called MonitorControl on a M1 16" MBP running Sonoma that adjusts both the MBP screen and external HP 25f monitor. It adjusts the brightness and contrast of whichever screen the cursor is in.
From MonitorControl's GitHub README, emphasis mine:
> Most modern LCD displays from all major manufacturers supported implemented DDC/CI protocol via USB-C, DisplayPort, HDMI, DVI or VGA to allow for hardware backlight and volume control.
And a blog entry by the author of Lunar, an app mentioned elsewhere for this problem: https://alinpanaitiu.com/blog/journey-to-ddc-on-m1-macs/
These are not examples of "just works". Apple intentionally does these things to cripple integration into non-Apple products.