Прямой подход через SQL Имена :
await db.any('SELECT * from $1:name', [table]);
// or
await db.any('SELECT * from ${table:name}', {table});
И со схемой:
await db.any('SELECT * from $1:name.$2:name', [schema, table]);
// or
await db.any('SELECT * from ${schema:name}.${table:name}', {schema, table});
Более обобщенный c подход через TableName :
const tn = new pgp.helpers.TableName({schema, table});
await db.any('SELECT * from $1', [tn]);
// or
await db.any('SELECT * from ${tn}', {tn});