How do I get a random image from subset of images in media gallery?

You can use taxonomies with the media library, you just need to either add a built-in taxonomy, or register a new one.

For example, adding the built-in post tag taxonomy to attachments:

function wpd_attachment_taxonomy() {
    register_taxonomy_for_object_type( 'post_tag', 'attachment' );
}
add_action( 'init', 'wpd_attachment_taxonomy' );

You can then query for images with a specific tag:

$args = array(
    'post_type' => 'attachment',
    'post_status' => 'inherit',
    'tag' => 'tagged',
    'posts_per_page' => 1,
    'fields' => 'ids',
    'orderby' => 'rand'
);

$image = new WP_Query( $args );

if( $image->have_posts() ){
    $image_attributes = wp_get_attachment_image_src( $image->posts[0], 'full' );
    echo $image_attributes[0];
}

Change tagged to whatever the slug of your chosen tag is. This will get the attachment ID of one random image with your tag. We can then use that ID to get the attachment image attributes.