Is there a way to de-orphan users without setting context to a restored database?
When creating the login principals, set the SID of the login to the original login.

Original server select name, sid from templatedb.sys.database_principals to get the SID

New server create login MyAdmin with password = 'DummyPassword951', sid = 0xBCB4D3AC87D6F449979D6810B8E9E250

Edit: FYI MyAdmin is the owner of the template database and is mapped to the dbo user. In the installed version of the database, I have mapped the MyAdmin login to the dbo user, using the dbo SID from the template DB.