pg_dump can only dump a single DB. The manual:
pg_dump only dumps a single database. To back up an entire cluster, or
to back up global objects that are common to all databases in a
cluster (such as roles and tablespaces), use pg_dumpall.
pg_dumpall, on the other hand can only dump all DBs in the cluster, even if you provide a specific DB name in the connection string. The manual:
Specifies parameters used to connect to the server, as a connection
string. See Section 34.1.1 for more information.
The option is called
--dbname for consistency with other client
applications, but because pg_dumpall needs to connect to many
databases, the database name in the connection string will be ignored.
-l option to specify the name of the database used for the
initial connection, which will dump global objects and discover what
other databases should be dumped.
To dump some DBs but not all, use a shell script, like has been advised.
You may want to include commands to create each DB in the dump: