plugin development – Escape echo that contains external script in WordPress

I am trying to submit my first plugin to wordpress.org but got a message that Variables and options must be escaped when echo'd. My plugin will add an external script to the WordPress footer and I’m not sure how to escape the variable correctly.

This is my code:

function print_code() {

    $location = get_option('location_select');
    $footer_code = '<script  src="https://' . $location . '.domain.com" async defer></script>';
    echo $footer_code;
}
add_action( 'wp_footer', 'print_code' );

I’ve tried replacing the echo with esc_html_e but that did not really work, not sure anymore what I’m doing wrong at this point. Any help is greatly appreciated!