Why can't sa be impersonated in a procedure? In order to solve a request regarding temporarily giving elevated privileges to a user I noticed that it was not possible to use EXECUTE AS LOGIN = 'sa'; inside of a procedure, but I can't figure out the reason since the error message does not fit the situation.
Here's how to test it (I run this part as a sysadmin):
--Create the procedure with the impersonation
USE master;
GO

CREATE PROCEDURE impersonate_procedure
WITH EXECUTE AS OWNER
AS
BEGIN

    EXECUTE AS LOGIN = 'sa';
    CREATE LOGIN appname_owner WITH PASSWORD = 'randomlygeneratedpassword';

END;
GO


--The login who should receive the privileges temporarily
CREATE LOGIN ronaldo WITH PASSWORD = N'123StrongP@SSw0rd';
GO

CREATE USER ronaldo FOR LOGIN ronaldo WITH DEFAULT_SCHEMA = dbo;
GO

GRANT EXECUTE ON dbo.impersonate_procedure TO ronaldo;
GO

Now I try to execute the procedure while logged in as ronaldo:
--Fails
EXEC dbo.impersonate_procedure;
GO

I get the following error:

Cannot execute as the server principal because the principal &quot;sa&quot; does
not exist, this type of principal cannot be impersonated, or you do
not have permission.

When I make this (sysadmin again):
GRANT IMPERSONATE ON LOGIN::sa to ronaldo;
GO

The login ronaldo can execute the content of the procedure body successfully:
--Works
EXECUTE AS LOGIN = 'sa';
CREATE LOGIN appname_owner WITH PASSWORD = 'randomlygeneratedpassword';

But if he tries to run the procedure, the error remains and it is bothering me because:

the principal sa exists;
it's a type of principal that can be inpersonated;
the login ronaldo was granted the privilege to impersonate sa (but shouldn't be
needed since the procedure was created by a sysadmin with the clause
WITH EXECUTE AS OWNER.

Why do I get that error?
Please, remove the WITH EXECUTE AS OWNER and it should work
--Create the procedure with the impersonation
USE master;
GO

CREATE PROCEDURE impersonate_procedure
--WITH EXECUTE AS OWNER
AS
BEGIN

EXECUTE AS LOGIN = 'sa';
CREATE LOGIN appname_owner WITH PASSWORD = 'randomlygeneratedpassword';

END;
GO