setting taxonomy term to bulk posts using ids

I hope I understand this correctly. You can simply just add your post ID’s in an array and then use a foreach loop to loop through the ID’s and checking whether or not they have the term to assign or not, and if not, assign the term to the post

$post_ids = [4522, 4524, 4526, 4528, 4530]; // array of post ID's
foreach ( $post_ids as $id ) {
    if ( !has_term( 'footbal', 'sports', $id ) ) // Check if term is not yet attached to post 
        wp_set_object_terms (
            $id, // Post ID
            'footbal', // Term slug ( or can be term ID )
            'sports', // Taxonomy name
            true, // Only append the term, do not replace
        );
}