Create a new feature for a WordPress page

I need a page with a specific title to launch the template I designed.

For this purpose, I added the following code to the functions.php file and it created a new page for me:

$check_page_exist = get_page_by_title('Login', 'OBJECT', 'page'); 

if(empty($check_page_exist)) {
    $page_id = wp_insert_post(
        array(
        'comment_status' => 'close', 
        'ping_status'    => 'close', 
        'post_author'    => 1, 
        'post_title'     => ucwords('Login'), 
        'post_name'      => strtolower(str_replace(' ', '-', trim('Login'))), 
        'post_status'    => 'publish', 
        'post_content'   => ' ', 
        'post_type'      => 'page', 
        'post_parent'    => ' ',
        )
    );
}

But I have changed the attribute of the page and added the template (Login Page) to the page using the following code:

 <?php
    // template name: Login Page
  ?>

Now I want the page that I created with the above code to be replaced with this template instead of the default template.

Is there a way to change the page layout by editing the code?