Ownership can only be transferred if the current role is the owner or the object and has been granted the destination role.
Examples
demodb.public/<no-store># LIST DATABASES;Name|Default|Owner|Createdat|Updatedat---------+---------+----------+----------------------+-----------------------demodb|✓|sysadmin|2023-09-10T20:59:20Z|2023-09-10T20:59:20Zdemodb.public/<no-store># GRANT OWNERSHIP ON DATABASE demodb TO rol1;demodb.public/<no-store># LIST DATABASES;Name|Default|Owner|Createdat|Updatedat---------+---------+-------+----------------------+-----------------------demodb|✓|rol1|2023-09-10T20:59:20Z|2023-09-10T20:59:20Z