Hello,
It depends how is used the picture.
For example, you can easily change a CSS background regarding the theme:
.theme-fandomdesktop-light div { background-image:url("light.png"); }
.theme-fandomdesktop-dark div { background-image:url("dark.png"); }
It can be dirtier with hard-coded images. For example:
Wikicode
<div class="forLightTheme">[[File:light.png]]</div>
<div class="forDarkTheme">[[File:dark.png]]</div>
CSS
.theme-fandomdesktop-light .forDarkTheme { display:none; }
.theme-fandomdesktop-dark .forLightTheme { display:none; }
That said, I dont know if it could be easily done with Javascript.