You can’t by default. There’s only a few attributes that are whitelisted for <img> tags. You can find those here:
Whitelisting specific classes can be done but would require a plugin.
How often do you plan on using this? You might be able to make something work with a theme component but the implementation will depend on your use case. Can you share a specific example of what you’re trying to do?
for example, you can wrap the image in something like
<div data-theme-banners>
<img src='foo'>
</div>
then you can use the selector
[data-theme-banners] img