First, I'll attempt to fill in the gaps in his backstory. We are told that Trunn killed a family of foxes except for one who he crippled and brought alive. It is implied that the wildcat only spared Groddil because of his abilities as a magician. Although we don't know the backstory, it is likely the wildcat was either looking for recruits for the Blue Hordes or conquering the region and gave them orders to vacate. Groddil's family was killed instead of becoming part of Trunn's horde. Although we aren't told what Groddil's family was like, they refused Trunn's orders or otherwise displeased him in some way. This is a clear contrast to other recruits such as Ripfang and Doomeye, who clearly enjoyed their job. Trunn, who was far more ruthless than his brother Verdauga Greeneyes, later bullied and belittled Groddil, contributing to the fox's hatred of him.
It is important to note that Groddil was forced to serve his master. However, he knew his abilities made him too valuable for the wildcat to kill him outright. The fox's abilities at creating illusions helped the wildcat in intimidating his enemies. It is mentioned in chapter 10 that although Trunn thought little of prophecy or visions, he relied on the fox's abilities when the badger Lord Brocktree clouded his dreams. However, Trunn's comments such as "I should have slain you with the rest of your family" and "I must have damaged your brain when I crippled your back" showed just how little the wildcat thought of him.
Groddil (and some of the Blue Hordebeasts as well) followed Trunn's orders not out of loyalty, but fear. When Groddil and a horde captain failed to bring Stonepaw and his hares back the first time, they were staked out on the shore and beaten unconscious by Ripfang and Doomeye as an example for the rest of the horde. After failing a second time, Groddil, Fraul and Mirefleck were turned over to the two searat brothers who treated them cruelly and forced them to find the rest of the hares. Finally the fox was able to escape Ungatt, Ripfang, and Doomeye, and swore vengeance on his former master, the central villain in the book (something many characters have done throughout the series).
Though Groddil disobeyed the wildcat and ordered the hordebeasts to kill Stonepaw, the book mentions he did this out of fear. (At first, he, ordered their hordebeasts to follow Trunn's orders and restrain Stonepaw and take him alive.) Being crippled, he would have been an easy target for the powerful badger lord and acted quickly out of self-preservation.
In short, Groddil's more powerful master abused and bullied him and gave him every reason to hate him. His final act of pushing Trunn back into the sea was simply one of retribution. Given the way he was treated, what goodbeast or vermin wouldn't have done the same thing? Lastly, it's mentioned in the book that he did not return to Salamandastron again. Possibly he returned to the Northlands where he lived out the rest of his days. To conclude, I believe Groddil shows more evidence of being the lone grey character fox in the Redwall series than evidence he was a villain.