How to exclude posts from category posts count

Assuming you have a list containing the post IDs you want to exclude, you could start with something like (PHP 7.3):

function exclude_posts_from_category( array $cat_args ): array {
    $exclude = array(); // TODO Add post IDs to exclude.
    $cat_args['exclude'] = $exclude;
    return $cat_args;
}
add_filter( 'widget_categories_args', 'exclude_posts_from_category', 10, 1 );

You can read about the widget_categories_args filter here. Additionally, you can alter the $cat_args array using a combination of arguments that can be found in the documentation of the wp_list_categories() function.

I did not fully test this code, so let me know in case you’re having any trouble.