I use Brightness Sync (https://github.com/OCJvanDijk/Brightness-Sync) for my external LG 5K screen attached to my iMac.
The iMac light sensor controls the brightness of both monitors automatically. You can even insert a fixed offset to match the absolute brightness of both monitors.