Changing roles is already possible in Postgres. You must be a member of the target role or be a superuser in order to change roles.
This is going to change in detail as of version 16 of PostgreSQL. You may determine whether a role switch is allowed or not.
Excerpt from https://www.postgresql.org/docs/16/sql-grant.html:
SET option, if it is set to
TRUE, allows the member to change to the
granted role using the
command. If a role is an indirect member of another role, it can
SET ROLE to change to that role
only if there is a chain of grants each of which has
SET TRUE. This option defaults to
-- Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012
Description: OpenPGP digital signature