Sanitize title only if only custom post type

you want to sanitize the title or the post_name (slug)?

if you want to filter post_name you can check wp_unique_post_slug filter or you can use the wp_insert_post_data filter to filter all post data before insert or update in db.

add_filter( "wp_unique_post_slug", "url_sanitizer", 10, 4 );
function url_sanitizer( $slug, $post_ID, $post_status, $post_type ) {
    // get original title by $post_ID if needed eg. get_the_title($post_ID)
    if( $post_type == "your_cpt" ) {
        $slug= str_replace( ' ', '_', $slug);
        $slug= str_replace( '-', '_', $slug);
    }
    return $slug;
}

Reference:

wp_unique_post_slug documented in wp-includes/post.php Line No. 3790
wp_insert_post_data https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)