Theoretically? Sure, I don’t see why not.
Practically? No, because both BIOS and UEFI firmware is specific to your mainboard model and revision. The maker could do it. You cannot.
There’s also practical problems, especially concerning the flash ROM size. UEFI firmware is much larger and even modern mainboards sometimes have to drop their fancy UEFI setup because suddenly the updated CPU compatibility module requires that space.
The easiest solution is probably to use an internal USB flash drive, possibly a so-called Disk on Module.
See coreboot for a similar project; it aims to replace BIOS/UEFI firmware with the open source coreboot firmware. It is relatively well-documented and offers insight into the challenges encountered.