We don’t use the name as an ID, just a number. You can find a theme’s ID by looking at the URL when you’re customizing a theme in the admin panel… for example https://forum.example.come/admin/customize/themes/140
If you can get by with the ID and not the name, this would be a quick way to do it (added to your theme/component’s head file):
<script type="text/discourse-plugin" version="0.8">
var themeSelector = require('discourse/lib/theme-selector');
document.querySelector("body").classList.add("theme-id-" + themeSelector.currentThemeId())
</script>
You could also find the theme name by ID, but it would take a little more work.