Cannot induce exit code 3 from psql
Got it to work a few ways:

postgres@ironforge:~$ cat onerrorstop.sql 
\set ON_ERROR_STOP on
select * from gurumeditationerror;
postgres@ironforge:~$ psql -f 'onerrorstop.sql'
psql:onerrorstop.sql:2: ERROR:  relation "gurumeditationerror" does not exist
LINE 1: select * from gurumeditationerror;
                  ^
postgres@ironforge:~$ echo $?
3
postgres@ironforge:~$


and: 

postgres@ironforge:~$ echo "\set ON_ERROR_STOP on
&gt; select * from smellyfarts;" | psql
ERROR:  relation "smellyfarts" does not exist
LINE 1: select * from smellyfarts;
                  ^
postgres@ironforge:~$ echo $?
3
postgres@ironforge:~$


and:

postgres@ironforge:~$ cat onerrorstop.sql 
select * from gurumeditationerror;

postgres@ironforge:~$ psql -v ON_ERROR_STOP=on -f 'onerrorstop.sql' 
psql:onerrorstop.sql:1: ERROR:  relation "gurumeditationerror" does not exist
LINE 1: select * from gurumeditationerror;
                      ^
postgres@ironforge:~$ echo $?
3
postgres@ironforge:~$ 

Version:

    postgres@ironforge:~$ psql --version
    psql (Post greySKULL) 9.5.19
    postgres@ironforge:~$