Elephants are explicitly mentioned in the war of Lanka in the Valmiki Ramayana, particularly in the Yuddha Kanda. They are not merely metaphors; the text describes elephants as part of the Rakshasa army and as being used in battle.
A few particularly clear references:
Yuddha Kanda 37. Vibhishana describes the military strength
of Lanka, including 10,000 elephants, 10,000 chariots, 20,000 cavalry, and a
very large infantry force.
Yuddha Kanda 53.10–11. This is one of the strongest
passages. The Rakshasa warriors are described as mounted on elephants, with the
elephants equipped for warfare and ridden by warriors carrying tomaras (lances)
and elephant goads. The elephants are described as being in rut and resembling
moving mountains.
विचित्रवाससः
सर्वे दीप्ता राक्षसपुङ्गवाः ।
गजा मदोत्कटाः शूराश्चलन्त इव पर्वताः ॥
vicitravāsasaḥ sarve dīptā rākṣasapuṅgavāḥ |
gajā madotkaṭāḥ śūrāś calanta iva parvatāḥ ||
“All the foremost Rākṣasas, splendid and dressed in various
garments, were heroic; [riding] elephants fierce with the intoxication of rut,
they appeared like moving mountains.” (6.53.10)
“They were mounted by warriors skilled in battle, with
tomara lances and elephant-goads in their hands. Others, possessing
auspicious/characteristic marks, were mounted by mighty and heroic warriors.”
(6.53.11)
Here tomara is a type of spear/lance, while aṅkuśa is the
elephant goad. Thus this verse makes the military role of the elephants
particularly clear: warriors were mounted on them and carried weapons and
elephant-goads.
Yuddha Kanda 44.8. During the fighting, the Vanaras attack
and drag elephants and their riders, even tearing them apart with their teeth.
Yuddha Kanda 93.11 and 93.35. The battlefield is described
using imagery involving dead elephants, chariots, horses and infantry. One
verse compares the rivers of blood to rivers whose banks are elephants and
chariots.
There are also references to elephants before the main
battle. When Hanuman surveys Lanka, he describes the city as filled with
elephants, chariots and Rakshasas.
In Valmiki Ramayana, the army of Ravana in Lanka is
portrayed as a conventional chaturanga military force, including elephants,
chariots, cavalry and infantry. The elephants could be ridden by Rakshasa
warriors and were involved directly in combat.