How can I put a checkbox in the post editor

Your code is correct and is ready for a number field. To make it work for a checkbox, you just need to change the type attribute of the input element from number to checkbox and manage the checkbox state. I think this should work:

add_action( 'add_meta_boxes_post', "spiaggia_add_meta_box" );

function spiaggia_add_meta_box(){
    add_meta_box(
        "spiaggia_meta_box",  
        __( "Checkbox Title", 'textdomain' ),  
        "spiaggia_meta_box_render",   
        "post",   
        "side"   
    );
}

function spiaggia_meta_box_render( $post ){

    // Get the checkbox state and display it
    $checkbox_state = get_post_meta( $post->ID, "function_spiaggia", true );
    $checked = $checkbox_state == 'yes' ? 'checked' : '';
    echo '<div><input type="checkbox" name="function_spiaggia" value="yes" ' . $checked . ' /> Check me</div>';
}

// Hook into the save routine for posts 
add_action( 'save_post', 'spiaggia_meta_box_save');

function spiaggia_meta_box_save( $post_id ){

    // Check to see if this is our custom post type 
    if($_POST['post_type'] == "post"){

        // Retrieve the checkbox state from the form
        $checkbox_state = isset($_POST['function_spiaggia']) && $_POST['function_spiaggia'] == 'yes' ? 'yes' : 'no';

        // Save the updated data into the custom post meta database table
        update_post_meta( $post_id, "function_spiaggia", $checkbox_state );
    }
}

Take that for a spin.

tech