The product code is always available as a property, no matter what you put into the @ProductCode
. So, the following should work for your case:
<RegistryKey Root="HKLM" Key="My Product">
<RegistryValue Name="TheProductCode" Type="string" Value="[ProductCode]" KeyPath="yes" />
</RegistryKey>
Besides, it can be put not only in the registry value, but the registry key name:
<RegistryKey Root="HKLM" Key="$(var.RegistryRoot)\[ProductCode]">
...
</RegistryKey>