The first work of fiction to contain shapeshifting is our old friend 'The Epic of Gilgamesh', generally regarded as the first work of literature ever written, ever, anywhere, written circa 2100 BC.
During their trip into the forest, Gilgamesh and his companion Enkidu encounter a forest demon named Humbaba. This chirpy little fella changes form and fights them for several hours.
Humbaba spoke to Gilgamesh, saying:
..An idiot' and a moron should give advice to each other,
but you, Gilgamesh, why have you come to me!
Give advice, Enkidu, you 'son of a fish,' who does not even
know his own father,
to the large and small turtles which do not suck their mother's milk!
When you were still young I saw you but did not go over to you;
... you,... in my belly.
...,you have brought Gilgamesh into my presence,
... you stand.., an enemy, a stranger.
... Gilgamesh, throat and neck,
I would feed your flesh to the screeching vulture, the eagle, and
the vulture!"
Gilgamesh spoke to Enkidu, saying: "My Friend, Humbaba's face keeps changing!·
The implication is that Humbaba is changing forms in order to find some way of countering Gilgamesh's mighty attacks. Eventually Shamash summons winds from the four corners of the Earth to overwhelm Humbaba and Gilgamesh is able to kill him.
Shamash raised up against Humbaba mighty tempests'--
Southwind, Northwind, Eastwind, Westwind, Whistling Wind, Piercing Wind, Blizzard, Bad Wind, Wind of Simurru,
Demon Wind, Ice Wind, Storm, Sandstorm--
thirteen winds rose up against him and covered Humbaba's face.