Abigail is potentially autistic and the handshake may be therapeutic
While not called out specifically, Abigail shows behavior which may indicate some level of autism. A good summary is from this review:
At one point, Maggie says she needs Peter to prove himself by bringing her a young girl, Abigail (Avery Kristen Pohl) from the school Peter substitute teaches at. This little girl exemplifies autistic-like tendencies: she's withdrawn, does not really speak, and focuses on building extremely detailed lego structures.
Emphasis mine. Large portions of Abigail's background are probably intentionally left out of the movie, so that we aren't given any convenience to deny Maggie's claims. However, Abigail may have been instructed to come up with a secret handshake by a social worker, therapist or even her father. Shaking hands and saying goodbye is not necessarily a simple thing for a person on the autistic spectrum.
The most specific example I found is only surviving right now is cached on Google, in a list of tips for parents dealing with the autistic kids and school:
- Develop a set of rituals, for example: (a) a “chit-chat” ritual at bedtime (e.g., ask your youngster about the happy, sad, scary and frustrating parts to his or her day; (b) a goodbye ritual (e.g., develop a secret handshake with your youngster that’s used only when he or she leaves you; (c) an after-school ritual (e.g., let your youngster have a snack and play outside for 30 minutes before starting homework); (d) an end-of-the-week ritual (e.g., have a “family night” every Saturday to reconnect and unwind after a busy week).
So it might not have been something developed with a friend, it could be her father or someone else in her support network.