I don't think that there is a good way to implement this requirement. Locking does not help, because locking only allows the owner of the lock to modify the page, but no other person.
The only way which will work is to create an group, make these 2 users member of it and give the group the permission to modify the page. When this operation is completed, remove the group. This is cumbersome, and will create a huge amount of dynamically created groups, which come and go.
Instead I would question the business workflow. I don't know the details behind your requirement, but before I would start to implement such an approach, I would try to find another way which can be implemented with less customizations.