Certainly.
Andy Griffith was the series’ producer and so he would have been well-aware that Nabors was gay. However it being the 1960s, he needed to remain closeted so that Griffith wouldn’t have to fire him as the network executives were unlikely to be supportive of homosexuality in that era. Jim Nabors remained low-key and he managed to have a decent career during the 1960s and 1970s.
Don Knotts would have likely known as he interacted with Nabors on a number of episodes while they were on the series. Since there are no records of Knotts being a homophobe and since there’s also no record of him being jealous of his costars, Knotts seems to have taken a similar route as Griffith and ignored Nabors’ personal life. This seems to be reinforced by the fact that as the breakout star of the series, Knotts had a great deal of clout and could have had Nabors fired if he chose to do so.
Nabors, for his part was discreet and he went along with storylines which attempted to portray his character as straight and “butch” (He joined the Marines after all) so there was never the issue of his accidentally “outing” himself. In fact, until Nabors relocated to Hawaii in the late 1960s (which was code for “gay man” at that time) there were no rumors about his sexual preferences.
All three men on the series:

