Praying in the presence of others is neither sinful nor inappropriate. Jesus prayed publicly (cf. Jn. 11.38ff; Mt. 26.26f; Mk. 8.6; etc.), as did his disciples (cf. Acts 16.25; 2.42; etc.).
But praying publicly simply to be seen by others is highly unethical (Mt. 6.5). Those who pray for show “have their reward” (lit., to have one thing while being far away from something else) — in other words, human praise will be the only praise they will ever receive!
Instead, the godly individual takes no interest in how others perceive his prayers (cf. Dan. 6.10ff), for he will
(1) “enter” into his “closet” (lit., inner storage-chamber) — i.e., not a physical room, but the hidden place of the heart (cf. Ps. 51.6; 91.1);
(2) “shut the door” — i.e., free himself of any external distractions; and
(3) literally, “pray to your in-the-hidden-place father” — i.e., commune with him alone in the heavenly environment (cf. Lk. 17.21; Heb. 4.16; Eph. 3.17; 2.6).
In short, whether you utter your prayers in isolation or in public view, be alone with God as your audience and judge. Retreat to your inner, spiritual “closet” and shut the door, desiring “to be seen” by the Lord, not man (Col. 3.23-24). Only then will he reward you “openly” (outwardly).