It is rather a WiX question. If your code above works then you can just inject it:
project.Compiler.WixSourceGenerated += doc => { doc.Root.Select("Product") .Add(XElement.Parse("<your fragment XML>"); };