How do I use the input from a \prompt in a conditional (\if)?
You can accomplish this using using \gset to coerce the variable into a boolean which \if can use,

$ cat if_prompt.sql 
\prompt 'enter abc here: ' x
select ('abc' = :'x') as is_abc \gset
\if :is_abc
  \echo you can read
\else
  \echo you are illiterate or impertinent
\endif


Testing it,

$ psql test -f if_prompt.sql 
enter abc here: abc
you can read

$ psql test -f if_prompt.sql 
enter abc here: 123
you are illiterate or impertinent