Yes, but this depends on how these HTML parts are added to the vendor template, have you inserted them via the template filter hooks? If listing or vendor objects are available in the template context then the snippets you suggested should be ok.
Thank you Yevhen, I know how to add custom classes this way, that is not my main problem. The problem is how to include the if statement, I mentioned above, in your snippet. Or in detail, how to check, if the vendor has a specific attribute set before adding the class to the listing container.
Please try this PHP snippet as an example of how to get a vendor attribute in the listing template and use it as a condition
// Get listing.
$listing = $template->get_context('listing');
// Get vendor.
$vendor = $listing->get_vendor();
// if vendor has some attribute value.
// if vendor does not have some attribute value.