Mastodon now supports automatic switching between the light and dark theme, depending on your system setting.
It will be available in the upcoming 4.3 version, or is already there if your instance runs the nightly code.
You can switch to this new automatic theme in your Appearance preferences. Instance admins can also set it as the default theme (I just did it on mastodon.social and mastodon.online).
This has been done in https://github.com/mastodon/mastodon/pull/29748, thanks a lot to @nshki for the initial PR!