First of all, you need to add below code in a new file and save as my-page-template.php.
This code simply tells WordPress that this is a template file and it should be recognized as “My Page Template”. You can change the template name anything you want as long as it makes sense to you.
<?php /* Template Name: My Page Template */ ?>
After creating the above php file. Upload your file inside /wp-content/themes/directory.
Now you need to login to your WordPress site & create a new page. On the page editing screen, You’ll see a template drop down menu. Clicking on it will allow you to select the template you’ve just created.