Hide a product with a certain tag from product-category

You should be able to add to your condition:

if (is_shop() || is_product_category()) {

This will exclude products with the tag from both the shop page and all product categories. You may also want to add || is_product_tag() to make sure they don’t show up on tag archives. WooCommerce’s conditional tags reference can help you find all the conditions you may be interested in using.