Is there a mechanism to hook into firmware updates?

I might have used wrong search terms, but I could not find any info regarding a mechanism to hook into firmware updates. I am using a Pi Zero 2 with a power management hat. It works flawlessly, except for powering down correctly after firmware updates. I am still looking into the reasons, but it is somehow related to firmware updates.

So I would like to try trigger some GPIO changes when rebooting before and after a firmware update. Any ideas how to accomplish that?