Thanks for the suggestions. The solution I came up with can be seen at https://github.com/intersystems-community/vscode-per-namespace-settings

It installs a class, runs a method in it to create the web app so it uses the correct namespace, then deletes the class. Actually, it deletes a whole package which I named %Z.IPM.Bootstraps with the idea that this could be by convention a package reserved for exactly this purpose.

I had to devise a little hack to prevent the deletion from happening during packaging, otherwise the web-app-creating class wouldn't actually be in the package, meaning end-user installation would fail.

Maybe there's already a better way of achieving the effect I wanted.