How to conditionally add Custom Post Type to Front Page

I believe that if all your products have the custom meta field show_on_front_page with some containing '1' and some containing '0' or some such, AND your regular posts do not have that field, then something like below should work:

//...
$query->set('post_type', array('post', 'product'));
//add this
        $meta_key = 'show_on_front_page';
        $query->set('meta_query',
                array(
                    'relation' => 'OR',
                    array(
                        'key' => $meta_key,
                        'value' => '1',
                        'compare' => '='
                    ),
                    array(
                        'key' => $meta_key,
                        'compare' => 'NOT EXISTS'
                    )
                )
        );
//...

Caveat: If some of the products don’t have the meta field set to anything they will show as well.

See https://developer.wordpress.org/reference/classes/wp_meta_query/