This docs page should help you with this:
https://docs.joomla.org/How_to_override_the_component_mvc_from_the_Joomla!_core
NOTE: this does not work on its own, instead you need to create a plugin for your overridden controller:
There may be times when you need to override the Joomla! MVC Component to add new functionality or to completely customise the component. The MVC component can be completely overridden by using the same class names that are used in the component. This is achieved by loading a system plugin before the component is dispatched by the application.
You can create your own plugin to do this.
class plgSystemComContentOverride extends JPlugin {
public function __construct(&$subject, $config = array()) {
parent::__construct($subject, $config);
}
public function onAfterRoute() {
$app = JFactory::getApplication();
if('com_content' == JRequest::getCMD('option') && !$app->isAdmin()) {
require_once(dirname(__FILE__) . '/comcontentoverride/my_content_controller.php');
}
}
}
in your case you need to modify it to something like
class plgSystemComContentOverride extends JPlugin {
public function __construct(&$subject, $config = array()) {
parent::__construct($subject, $config);
}
public function onAfterRoute() {
$app = JFactory::getApplication();
if('com_user' == JRequest::getCMD('option') && !$app->isAdmin()) {
require_once(dirname(__FILE__) . '/../../templates/{template_name}/code/com_users/profile.php');
}
}
}