For Sharepoint modern Team site, is there a way to auto update on change of the group member? let's say, a permission group generated based on department, hence, any new member on board or staff offboard for that particular department, change will be reflected automatically in the permission group.
Isn´t their a Microsoft 365 Groups added to the site? I would also suggest to use Azure AD Security groups and add to the site.
Depending on you Azure AD licens, there are also way to populate groups depending on attributes of the user account.
So if a user changes department and this is reflected in the AD, he/she will automatically be set in the AD group and get access to the site right away.