I have resolved your issue by creating a frontend plugin
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Theme\Block\Html\Title">
<plugin name="product_title" type="Mbs\Title\Plugin\ProductTitleWithBrand" />
</type>
</config>
and then the plugin reads whether the page title to render is for a product registered in the registry as per product detail view.
class ProductTitleWithBrand
{
/**
* @var \Magento\Framework\Registry
*/
private $_coreRegistry;
private static $attributePrefix = 'brand';
public function __construct(
\Magento\Framework\Registry $_coreRegistry
) {
$this->_coreRegistry = $_coreRegistry;
}
public function afterGetPageHeading(\Magento\Theme\Block\Html\Title $subject, $title)
{
if ($this->getProduct()) {
$prefix = $this->getProduct()->getAttributeText(self::$attributePrefix);
if ($prefix) {
$title = $prefix.' '.$title;
}
}
return $title;
}
/**
* Retrieve currently viewed product object
*
* @return \Magento\Catalog\Model\Product
*/
private function getProduct()
{
return $this->_coreRegistry->registry('product');
}
}
see full code at https://bitbucket.org/magstaging/mbstitle