How to change admin menu position of “Media”?

There’s a combination of two filters, menu_order does the job, but you also use custom_menu_order to enable menu_order.

function wpse_233129_custom_menu_order() {
    return array( 'index.php', 'upload.php' );
}

add_filter( 'custom_menu_order', '__return_true' );
add_filter( 'menu_order', 'wpse_233129_custom_menu_order' );

This will put upload.php (the Media screen) just after the Dashboard and then the other top-level menu items will follow.

If you want to put Media elsewhere then just list all the other screens that should precede it in the array.

Alternatively you could directly address WP’s global $menu array:

function wpse_233129_admin_menu_items() {
    global $menu;

    foreach ( $menu as $key => $value ) {
        if ( 'upload.php' == $value[2] ) {
            $oldkey = $key;
        }
    }

    $newkey = 26; // use whatever index gets you the position you want
    // if this key is in use you will write over a menu item!
    $menu[$newkey]=$menu[$oldkey];
    $menu[$oldkey]=array();

}
add_action('admin_menu', 'wpse_233129_admin_menu_items');

Note the comment on the possibility of overwriting another menu item. Coding in a search for an array index that doesn’t collide is left as an exercise for the reader. This isn’t an issue if you use the first method, of course.

There’s something about fiddling with WP’s globals like this that makes me feel dirty. Changes to WP’s inner workings can mess things up for you. Use the abstractions provided by hooks and APIs when you can.