The Roman empire extended into North Africa and they would absolutely have been aware of the wildlife. Hannibal actually launched an attack on the Romans that involved bringing war elephants across the Alps [0]. Subsequent readers of Roman authors would have known about the animals the Romans knew about, e.g. [1], which in turn made their way into medieval bestiaries (along with unicorns and a few others).
[0] https://en.wikipedia.org/wiki/Hannibal%27s_crossing_of_the_A...
The name was reused in the 1800s, of course we don’t know it was actual gorillas that they encountered might have been other great apes.
Also there is no evidence this was a regular occurrence. Getting over the Sahara is extremely hard and ancient ships weren’t really fit for this type of journey due to the prevailing winds (some scientists today still doubt that Hanno the Navigator could have sailed further than West Sahara despite the written evidence..).
Anyway.. it’s extremely unlikely they were in direct contact and good luck getting any great apes across the desert. Also even if they did Carthaginian culture (and pretty much all written records) was pretty exterminated by the Romans.
"Ape", from Old English apa, is a word of uncertain origin. The term has a history of rather imprecise usage—and of comedic or punning usage in the vernacular. Its earliest meaning was generally of any non-human anthropoid primate, as is still the case for its cognates in other Germanic languages.
So the origin might actually be Indo-European.
the gallery on this website has over 100 illustrations of apes... some from the 12th century.