Victor,
Roles on pages can’t be set dynamically, these are assigned designtime and not runtime.
If you need to restrict data on a page for a user based on a role this can be setup dynamically with the use of entity access and xpath constraints on the entities. Not sure if this is what you are actually looking for though.