I can see Domain property of the User class doesn't have a setter, so you cannot do it programatically.
// Sitecore.Security.Accounts.User
/// <summary>
/// Gets the domain to which the user belongs.
/// </summary>
/// <value>The domain.</value>
public override Domain Domain
{
get
{
if (this._domain == null)
{
this._domain = Domain.GetAccountDomain(this.Name);
}
return this._domain;
}
}
"Domains" concept is the additional abstract level (as well as "RolesInRoles") provided by Sitecore over Asp.NET security model.
In reality it's just a prefix/part of the user name, which is stored in the Core database in the "aspnet_Users". So the "admin" user from the "sitecore" domain is presented as "sitecore\admin".
So to change user domain you need to rename the user in the "aspnet_Users" table via SQL Server Managemnet Studio.
Please note that renaming the domain can cause the issues with configured access right for a user. Because access right for the particular user for the specific item are stored in this item, and mapped to user name.
So when you changed user name, it will not be updated on the item level, and it can break security rights.