This happens because in the caller database you must add a reference to the dependent database and specify also a value for the database name.
Look below:
Then you can create your synonym using the following code:
CREATE SYNONYM [dbo].[mytable] FOR [$(MasterDatabase)].[dbo].[mytable]