It’s possible with some CSS, but I think it would be better to go the other way. In places where your H1 is sitting on top of a dark background, you should set the H1 to white. In most cases, there should be text color options in those areas that you can use.
Then you can keep the global H1 element dark, as your content area is white by default.
If that’s not do-able, you can use this CSS: