I think you can create it as a plug in. Documentation is here:https://docs.opnsense.org/development/examples/helloworld.html
I would not recommend retrofitting an ISO. You'll have to build the ISO and embed your code changes or install a plugin on the installed machine afterwards.Cheers,Franco