Customizing the core Magento 2 functionality is a bad coding practice. The solution is to override a phtml file using a custom module in Magento 2.
Attachment 14125
Methods to Override a phtml file using a custom module in Magento 2:
1. with plugin
2. with XML
Learn the implementation of both the methods at https://meetanshi.com/blog/override-...-in-magento-2/