Gutenberg blocks – template_lock with several post type

This is more of a PHP question than a WordPress one but you could do the following:

function wp_template_lock_example() {
    // Make an array of your post types
    $post_types = array('subject-imposed', 'subject-free', 'dissertation');

    // Loop the array and apply the template details to each.
    foreach ( $post_types as $post_type ) {
        $post_type_object = get_post_type_object( $post_type );
        $post_type_object->template = array(
            array( 'acf/text-introduction'),
            array( 'acf/text-paragraph')
        );

       $post_type_object->template_lock = false;
    }
}
add_action( 'init', 'wp_template_lock_example' );

Hope it helps!