Doing it with CSS sounds fairly straightforward: you can have two <img> tags for each logo type, set some CSS class adjacent to logo-container like logo-light or logo-dark, and use a child selector to make one of the two <img> tags either display: none or not.
I guess somehow in there something (JS) needs to toggle that CSS class, but I wasn't able to figure out how the existing theming works (I didn't see any other changes to the DOM when the themes are toggled on cursory inspection).
However, I think the default logo looks best on a dark background when inverted. If you only change the default logo, inverting it seems like the best solution to me.
Rather than attempting to bikeshed the easiest way to modify a Rust logo designed for a light background to work on a dark background, we should be asking the logo designer for a logo designed for a dark background.