How do I write portable SQL that refers to a linked server?
The name of your linked server doesn't have to be the server's name.  You can use a generic name.

EXEC master.dbo.sp_addlinkedserver
    @server = N'COMMONNAME',
    @srvproduct=N'MSDASQL',
    @provider=N'SQLNCLI',
    @provstr=N'DRIVER={SQL Server};SERVER=ACTUALSERVERNAME;UID=user1;PWD=rosebud567;', 
    @catalog=N'database1'


Set up the linked server on each environment with the same name, but actually point them at different servers.