Is it possible to modify the firmware used when the device is turned off? On (at least) some Samsung devices there is some piece of software that runs when the device is turned off. It is the one that displays the battery state when charging, along with the red/green indicator light. 

It is obviously tiny, native and device-specific. It is also probably (again, at least) somehow related to the initial bootloader that e.g. puts the system in recovery mode if needed. 

But would it be possible to modify that piece of software to, for example, change the light colors or other functionality? I'm really asking just in theory; even if extremely hard and non-practical, I'm curious if it would be possible. 

EDIT: Just clarifying here, but I mean the software that runs when the entire device is turned off, not just the screen. I have a Galaxy S3 LTE (GT-I9305, CyanogenMod 10.1, CWM recovery 6.0), and CyanogenMod actually allows me to change the light colors when just the screen is off.

Also, I don't necessarily want to change it by any means, I am just curious if it could be changed.

Here's what the software I mean looks like on my phone (sorry for the poor quality, obviously not taken with my phone :P):
Have your tried using Custom Roms... I believe AOPK and some others support light changes... Check it out :)

http://aokp.co/