Not conveniently on a single page rendered by the docs plugin, no, but you could insert it as a custom sidebar setup:
module.exports = {
myHtmlSidebar: [
{
type: 'html',
value: '<div class="my_ad_div"></div>',
defaultStyle: true, // Use the default menu item styling
},
],
};
Then, using the gtag plugin, you should be able to hoist the JS that loads the ad code, but show up only on pages where you put a container for it to land in the sidebar. This would take some juggling to manage, or you could swizzle some theme components directly. That leads me to the other option - wrapping it.
With Docusaurus, you also get a lot of the creature comforts that React has to offer (such as Helmet wrappers), which Docusaurus implements as <BrowserOnly>
.
You should be able to come up with something so you have somewhat granular control without breaking any upgrade paths, even if you end up writing your own little ad component.