You need to specify the namespace when you create the attribute:
attribute = doc.CreateAttribute("xsi:type", "http://www.w3.org/2001/XMLSchema-instance");
However this will add the xmlns declaration to the child node:
<doc>
<user xsi:type="CharTerm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</doc>
If you want it to be on the root element you need to declare it explicitly:
string xsi = "http://www.w3.org/2001/XMLSchema-instance";
var xmlns = doc.CreateAttribute("xmlns:xsi", "http://www.w3.org/2000/xmlns/");
xmlns.Value = xsi;
doc.DocumentElement.Attributes.Append(xmlns);
attribute = doc.CreateAttribute("xsi:type", xsi);
Then you get this:
<doc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<user xsi:type="CharTerm" />
</doc>