Magento 2: Is it possible to add a canonical link to a page through it's layout file?

Hope you are looking for this one

<head>
      <link rel="canonical" src="pageurl" src_type="url"/>
</head>

Please change the 'pageurl' as per your requirements. And place it in custom layout section in admin , if you want the functionality using admin custom layout section.

I have used this with one of my category.


Adding to Dinesh's answer, you can also use the {{baseUrl}} variable if you want to make the URL dynamic.

<head>
    <link rel="canonical" src="{{baseUrl}}mypath" src_type="url"/>
</head>