How to write this JSON-preparing, non-scalar query as scalar?
In your scenario, because you are using variables, it is sure that your query returns only one row (scalar), so you can ignore this warning.

To suppress the warning, you could add a TOP 1 to your query, but it is not necessary.

SET @json = (SELECT TOP 1
  @varchar1 as MyVarchar1,
  @varchar2 as MyVarchar2, 
  GetUtcDate() as MyTime FOR JSON PATH);


You can find more on https://documentation.red-gate.com/codeanalysis/execution-rules/ei003