This should work quite well.
JS (MediaWiki:Common.js):
var images =
[
"Link to img",
"Link to img",
"Etc."
]
var image = images[Math.floor(Math.random() * images.length)];
var stylesheet = mw.util.addCSS("body { --theme-body-background-image-random: url(" + image + "); }");
CSS (MediaWiki:Common.css):
.page__main {
background-image: var(--theme-body-background-image-random);
background-repeat: no-repeat;
background-size: cover;
background-position: top;
background-attachment: fixed;
}