How Change WordPress header image from admin menu

To be honest I don’t fully understand why you need this custom code to upload images, it should be possible with the default settings.

To answer your question:

If you dig a bit through the code, you’ll see that

  1. header_image() calls get_header_image() and returns that
  2. get_header_image() calls get_theme_mod('header_image', ...) and will return that (as long as its not remove-header or is_random_header_image() returns true).
  3. get_theme_mod() now finally introduces a filter: theme_mod_{$name}

So, the following filter should be able to change the header image to whatever you want:

add_filter('theme_mod_header_image', function ($originalValue) {
    // return URL to your desired image
});