Like this:
\d foo 
                 Table "public.foo"
  Column  |  Type   | Collation | Nullable | Default 
----------+---------+-----------+----------+---------
 fooid    | integer |           |          | 
 foosubid | integer |           |          | 
 fooname  | text    |           |          | 
alter  table foo add column bar varchar constraint u2_idx UNIQUE;
ALTER TABLE
 \d foo
                      Table "public.foo"
  Column  |       Type        | Collation | Nullable | Default 
----------+-------------------+-----------+----------+---------
 fooid    | integer           |           |          | 
 foosubid | integer           |           |          | 
 fooname  | text              |           |          | 
 bar      | character varying |           |          | 
Indexes:
    "u2_idx" UNIQUE CONSTRAINT, btree (bar)
UPDATE.
To get closer to what the post you linked to shows:
alter  table foo add column baz varchar default ''  constraint nn_constraint NOT NULL;
\d foo
                             Table "public.foo"
  Column  |       Type        | Collation | Nullable |        Default        
----------+-------------------+-----------+----------+-----------------------
 fooid    | integer           |           |          | 
 foosubid | integer           |           |          | 
 fooname  | text              |           |          | 
 bar      | character varying |           |          | 
 baz      | character varying |           | not null | ''::character varying
Indexes:
    "u2_idx" UNIQUE CONSTRAINT, btree (bar)
Though the NOT NULL  constraint does not actually get named.