How to modify this function to exclude also the post belonging to a specific category?

pre_get_posts and WP_Query uses the exact same parameters, so if you need to know which parameters you can use with pre_get_posts, simply visit the WP_Query page in the codex.

There is another trick which you can use to get all the parameters (query_vars) you can use. Just add this on the page that you need to get the query_vars from, refresh the page, and this function will print out all the query_vars you can use with pre_get_posts and WP_Query

<?php global $wp_query; ?>
    <pre><?php var_dump($wp_query->query_vars); ?></pre>
<?php

To exclude a category, you can either use cat or category__not_in. Both take category ID’s, cat take integers and category__not_in an array. So one of the following will do in your function

$query->set( 'category__not_in', array(ARRAY OF CAT ID's));

OR

$query->set( 'cat', 'ID's OF CAT');

You just have to make sure, your callback function in add_action and your actual function name does not match. exclude_featured_tag must be exclude_featured_tag_and_legacy_posts