How to display Custom Post Type Post based on Tag with Shortcode Parameter?

This is an answer that depending on how you ultimately configure things – should get you where you want to go.

In your question, you had posts_per_page as 1. If you only want 1 result, then that’s fine. If not… modify as shown.

You also didn’t initialize the concatenated string $return_string and finally you put the reset after the return, so it had no effect.

function display_casestudy( $atts ) {

    $handlearray = shortcode_atts(
        array(
            'tag' => '',
        ),
        $atts
    );

    $cstag = sanitize_text_field( $handlearray['tag'] );

    $args = array(
        'post_type'      => 'case_studies',
        'posts_per_page' => -1, // Putting -1 allows all results.
        'tax_query'      => array(
            'relation' => 'AND',
            array(
                'taxonomy' => 'post_tag', // Use Your Taxonomy Type Here.
                'terms'    => $cstag,
                'field'    => 'slug', // This depends on how your're passing it in the $cstag.
            ),
        ),
    );

    $query         = new WP_Query( $args );
    $return_string = '';
    // The Loop.
    while ( $query->have_posts() ) :
        $query->the_post();
        $return_string .= '<li><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></li>';
    endwhile;

    wp_reset_postdata(); // Put before Return otherwise it does nothing.
    
    return '<ul>' . $return_string . '</ul>';
}

error code: 521