This post is a contribution from Pavan Kumar, an engineer with the SharePoint Developer Support team.
As in SharePoint 2007 and 2010, one of the ways to achieve this is to use FeatureStapling. Below are the steps to be followed to get this working.
Create a SharePoint 2013 Empty project in Visual Studio 2012 and give it a name (e.g., ChangeMySiteMaster).
Provide your MySite Host URL and choose to deploy this as a farm solution.
Add a new Module from Visual Studio 2012 SharePoint item templates to the project.
By default, MySites use mysite15.master as its default master page. This can be found under 15\TEMPLATE\FEATURES\MySiteMaster\mysite15.master. Copy this file and add it to the project you created. Rename it to CustomMySite.master and modify this file per your needs.
Delete Sample.txt available in the Module and edit Elements.xml file such that it looks like this: