Change permissions or add roles on the fly
Adding permissions on the fly would be hard without writing your own module.

However, maybe there are round-about ways of accomplishing what you need.  Two suggestions:

1) You can add a taxonomy field to your user account that can be set and then use the rules module to automatically add new users to a certain group based on the terms they were tagged with during creation... 

2) If you go to: admin/config/group/permissions/node/group, you can see that you can set permissions for members, non-members and admin members of a group, and you can set the 'add user' permission depending on those user group roles.  If you set those to your liking, your workflow can then be a 2-step process: 1) create user account, 2) add user to whatever groups you need.  It's more cumbersome, since it's a 2-step process, but only members or managers of a group will be able to add users to that group.

Final note: creating/editing permissions on the fly like you're thinking may have unintended consequences.  You're saying that users should not be allowed to edit other groups, but if you try granting and revoking permissions based on opening and then submitting a form, you'll actually be giving users the ability to administer all groups until they submit that form!  If they forget and don't submit it or leave it open in their browser for a long time, they'll potentially have that admin-level permission and see all relevant links, blocks and associated admin sections for a long time.  So I suggest you try an approach like the above then attempting to grant 'temporary' permissions.  :-)