What do you do when Sonic is sitting on the other side of the stage charging up his spindash? Can't rush him because he'll just release and bump into you, but if you wait then he just starts flying all over and you don't know what he's going to do.
Well, what character are you using first of all? If you have projectiles, use them... same for anything that can help you space (certain aerials, tilts, characters with swords, and etc). Basically anything with greater range than Sonic's normals with decent execution time.
As a Sonic main, I fight many people like you who are sort of confused and freeze up due to Sonic's unpredictability. Make him predictable and bait him into making mistakes.
Dodge homing attack when possible, and chase him down when he runs away (beware chasing him down while he's dashing though :lol). A lot of the time Sonic's will actually use moves to escape, and some do not react well when they have no space and are facing constant pressure. So try to make them uncomfortable). Grab him whenever possible, and stay close to the edge when you see him charging any spin move. He has a bit more KO potential, but all of his KO moves are still really predictable.
If you ever want a Sonic to practice against here's my FC: 5215-0711-9638