Your close:
{% if product.tags contains 'noindex' %}
{% endif %}
The merchant doc to hide shopify pages from crawlers:
https://help.shopify.com/en/manual/promoting-marketing/seo/hide-a-page-from-search-engines
And using a metafield such as through bulk editing
https://shopify.dev/apps/marketing/seo#step-2-hide-a-resource-from-search-engines-and-sitemaps