How to exclude products by tag from woocommerce shop page?

Add this to your functions.php

function custom_pre_get_posts_query( $q ) {

    $tax_query = (array) $q->get( 'tax_query' );

    $tax_query[] = array(
           'taxonomy' => 'product_tag',
           'field' => 'slug',
           'terms' => array( 'banana' ), // Don't display products with the tag "banana"
           'operator' => 'NOT IN'
    );

    $q->set( 'tax_query', $tax_query );
}
add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );