> You Can add This below Snippet code for  :

change your input value 'true' and add after `<?php  echo $sidebar?'checked': 'unchecked'; ?>` in input element

    function theme_post_sidebar_settings($post) {
    
        $sidebar = get_post_meta($post->ID, '_theme_post_meta_sidebar', true);
        wp_nonce_field( 'theme_update_post_sidebar_settings', 'theme_update_post_sidebar_nonce' );
        ?>
    
        <input type="checkbox" name="theme_post_meta_sidebar_field" id="theme_post_meta_sidebar_field" value="true" <?php  echo $sidebar?'checked': 'unchecked'; ?> />
        <label for="theme_post_meta_sidebar_field"><?php esc_html_e( 'Sidebar', 'theme' ); ?></label>
    
        <?php
    }