Obsidian already supports this natively since version 0.9.18:
You can now give notes specific CSS classes using the front matter option
cssclass. You can also specify multiple ones with the same syntax as tags and aliases, for example,cssclass: class1, class2. Combine this with custom CSS to selectively style notes.