That’s all quite possible by either forking the ad plugin, and potentially submitting a pr, or using it as a model to create one just for your ad network (which would give you more control, but would limit your audience to self hosted and other sites that can install arbitrary plugins).
You’re welcome to post on marketplace or check out the various plugin topics like this first one I found Developing Discourse Plugins - Part 2 - Connect to a plugin outlet.