Dimentio is capable of destroying dimensions
But since Sonic can still travel and operate without the need of dimensional space he should be fine. Since Mario can damage Dimentio with his melee attacks, Sonic should be capable as well considering he was able to defeat a being who absorbed a mass number of universes. Not only that, Sonic is capable of tanking an explosion at point blank that could create a low level multiverse. Sonic’s speed is so great that he was even capable of restoring time and space. This is all in base form by the way.
If Sonic uses his speed, he could have the advantage over Dimentio to deal damage before he unleashes anything colossal. Not only that but he has his Super form at his disposal if we are allowing Sonic to utilize the Chaos Emeralds.
Also I’m talking about Game Sonic, not Archie Sonic