I have got a project with a few dependencies, but I would like to ensure that some of them are NOT published to the ModuleMetadata when it’s generated. Is there a hook I can use to filter the dependencies before they get into the ModuleMetadata?
No, you need to properly declare the dependencies, so that the correct outcome is produced. There is no supported way to manipulate the GMM manually.
It is hard to advice how to do it properly without knowing more about the situation, but for example if you declare a dependency as compileOnly it will not end up in the GMM.