This is an excellent question. The answer involves a problem with many of the English translations that render Gen 21:17 something like the NASB: "God heard the lad crying … "
The verb translated "crying" here is קוֹל (qol) which simply means "sound" or "voice" and does not necessarily mean "crying". It occurs over 500 times in the OT and is very rarely translated or even implies "crying" - most often it is simply "voice", eg, Gen 3:8, 10, 17, 4:10, 23, 16:2, 21:12, 16, 18, 26:5, 27:13, 27:22, 38, 27:43, 29:11, 30:6, etc. Thus, there is no record of Ishmael crying.
By contrast, the verb translated "crying" for Hagar (v16) is בָּכָה (bakah). It occurs over 100 times and is most often rendered "crying" or "weeping", eg, Gen 23:2, 27:38, 29:11, 33:4, 37:35, 42:24, 43:30, 45:14, 15, 46:29, 50:1, 17, etc. Incidentally, Gen 21:16 is the first instance we have of someone weeping/crying in the Bible. This is understandable as Hagar's arrogance (Gen 21:9, 10) had significantly contributed to her situation.
Thus, we have in Gen 21:16, 17 a desperate mother and son in a desperate situation. The two responded in different ways - Hagar lamented and wept while the boy may have been either praying or trying to comfort his mother; or possibly a combination of the two. Either way, the boy is speaking and the angel of God responded (v17, 18).
The fact that the angel of God responded to the voice of the lad suggests that he may have prayed a simple childish prayer for help - a touching lesson for us all. This appears to be confirmed by another subtlety - God hears the voice of the lad and then speaks to Hagar. This suggests that Ishmael was praying for God to comfort his mother and God responded accordingly.