Remember that a Math formula is created outside Writer in an independent application (which in addition does not evolve at the same pace as the others). Once created, the formula object is handed over as a “frozen” one to Writer, just like an image, and won’t react in any way to UI customisation.
You didn’t tell why you chose the dark theme. If you intend to use the resulting document on screen (as a kind of presentation), you can play with the colours in Math so that the overall appearance matches Writer. But, if the document ends up printed, the simplest approach to avoid complicated management issue is to set your UI in Writer to look like a sheet of paper, i.e. a white background.
And if your document is effectively a presentation, build it with Impress which is specifically designed for the task.