Set a featured image as a replacement to the header image

You did not mention or shown in the code to which hook are you hooking the above code to, but here’s what I think should work. NOT TESTED

global $post;
$header_image="";

// featured image is first priority, right?
if ( has_post_thumbnail( $post->ID ) ) {
    $header_image = get_the_post_thumbnail_url( $post->ID, 'full' );
} elseif ( !empty( get_header_image() ) ) {
    $header_image = get_header_image();
}

$header_image_css = ".blog__header { background-image: url({$header_image}); }";
wp_add_inline_style( 'theme-styles', $header_image_css );