Logitech provide the Logitech G software for managing LEDs and other settings on keyboards and mice. Unfortunately this isn’t available for Linux.
There is a command line tool called g810-led that can fill this gap (https://github.com/MatMoul/g810-led). To install this on Ubuntu run:
sudo apt install g810-led
After installation you will probably need to reboot for the software to recognise the keyboard.
To list the keyboards that the software can see run
The software supports a number of G series devices, such as the G213, G410, G413, G512, G513, G610, G610, G810, G815 & G910.
To adjust the lighting on the G413 run
g413-led -a 444444
Sometimes the keyboard hardware will override the dimming, so if the commend completes successfully but the keyboard doesn’t respond try the <FN>-<F7> combination to see if the hardware override is in place.