The firmware payload is verified on-device using strong cryptography such as RSA, AES or ECC.
It is usually not possible to modify or flash custom firmware not provided by the vendor.