Heya!
This seems like an acceptable approach assuming you can accept that the access token will be valid until the point it expires. Hence if someones role was changed they could continue to access the function until the access token expired. This is the main reason ID and Access tokens should be short lived. If this isn't acceptable then you could use the graph API to get the role of the user at the point off calling the API.
To round this out a little more Azure B2C has custom attributes for these kinds of use cases as it is an attribute about the user which is slow moving and is shared across an application (or many applications). There is the alternative approach of storing the roles of a user in a separate store which you can get at the point of auth to attach to the token/have an authorisation service that the function calls directly.
Given it was the approach you asked about I would store the role claim in B2C and attach it on the token on the user authenticating.
Hope this helps.