I watched an animation about Sonic, and that hedgehog became a Super Saiyan using diamond shaped stuff.
What actually is that? How can Sonic become like that?
I think you're refering to what's commonly known as Super Sonic.
Sonic has had the ability to turn into Super Sonic using Chaos Emerald since the 2nd game. Various media have handeled this transformation in various ways (see the Wikia-page linked above), but in general he's seen as a yellow or golden version of himself. He usually gain enhanced speed and an ability to fly and/or to survive in outer space. At least in the games, this is often at expense of Rings.
The transformation is not directly linked to Super Saiyans, but it's widely believed that the game drew heavy inspiration from Dragon Ball in this regard. (No official confirmation, tough.)