How to get $post object available inside functions.php to localize script?

The wp action hook fires pretty early, before the $post object is set. I would suggest using the appropriate hook wp_enqueue_scripts instead, and amending your code to:

function profolio_localize_script () {
    if ( is_singular( 'my-gallery' ) ) {
        $layoutType = get_post_meta( get_queried_object_id(), 'gallery_layout', true );
        // Rest of code 
    }
}

tech