As per the document from PG-9.6 it is possible.
You cannot use psql variables with -c
“
command
must be either a command string that is completely parsable by the server (i.e., it contains no psql-specific features), or a single backslash command.”David J.