Filter WordPress Archive Widget to exclude posts with specific custom taxonomy term id

This would probably be best done using a custom WP_Query as opposed to a filter.

So say your site is about plants but you don’t want this custom archive to show posts where you have your plant custom taxonomy set to weeds:

$args = array(
   'post_type' => 'post',
   'tax_query' => array(
      'taxonomy' => 'plants',
      'field' => 'slug',
      'terms' => 'weeds',
      'operator' => 'NOT_IN',
   ),
);

$myArchive = new WP_Query($args);

So what this code is doing is creating a new query for posts looking at the slug for the taxonomy of plants and then grabbing them all except those with a slug name of weeds and then you can use the loop to display them however you want in the widget.

Just remember to use wp_reset_postdata() after the last post is displayed in your widget to reset $post back to the default query.