Yes, I know that sounds crazy but this actually happened and it occurred enough to find several instances of animals being put on trial.
These Animal Trials are recorded as having taken place in Europe from the thirteenth century until the eighteenth. They ranged from horses kicking their owners all the way to insects damaging crops. The earliest record of an animal trial is the execution of a pig in 1266 at Fontenay-aux-Roses. Such trials remained part of several legal systems until the 18th century. Animal defendants appeared before both church and secular courts, and the offenses alleged against them ranged from murder to criminal damage. Human witnesses were often heard and in Ecclesiastical courts they were routinely provided with lawyers (this was not the case in secular courts, but for most of the period concerned, neither were human defendants). If convicted, it was usual for an animal to be executed or exiled. However, in 1750, a female donkey was acquitted of charges of bestiality due to witnesses to the animal’s virtue and good behavior while her human co-accused were sentenced to death.
Animals put on trial were almost always either domesticated ones (most often pigs, but also bulls, horses, and cows) or pests such as rats and weevils. Creatures that were suspected of being familiar spirits or complicit in acts of bestiality were also subjected to judicial punishment, such as burning at the stake, though few, if any, ever faced trial.
According to Johannis Gross in Kurze Basler Chronik (1624), in 1474 a rooster was put on trial for “the heinous and unnatural crime of laying an egg,” which the townspeople were concerned was spawned by Satan and contained a cockatrice (dragon-like mythical creature). Alleged werewolves were put on trial on several occasions, particularly in sixteenth-century France, though the allegation in such cases was always leveled against human defendants.
Fortunately, it is now considered in most criminal justice systems that non-human creatures lack moral agency and so cannot be held accountable for an act.