Add different roles to user in registration based on some criteria

We have an application that is using KeyCloak for authentication and roles for access control.

Some registration is possible, and we need to give different role to users who register in different parts of the application. Is it possible to give users different roles based on some http mechanism? Like a query string parameter, or anything like that?