How to add same body class in multiple pages using their page id?

Note that you must always return the classes in your callback.

So move this part:

return $classes; 

out of the if condition.

The is_page() does support multiple ID’s when it’s in an array.

This should work:

add_filter( 'body_class', 'custom_body_class' );

function custom_body_class( $classes ) {
    if ( is_page( [ 38034, 10883, 12031 ] ) ) {
        $classes[] = 'new-class';
    }
    return $classes;
}

tech