There is a scene where he is arrested by GUN (Guardian Units of Nations), but he is later released after proving his innocence and helping to stop the villain, Shadow.
It's important to note that the concept of "jail" for a character like Sonic, who is superfast and capable of defying gravity, doesn't really make sense within the context of the Sonic universe.