Making a Sonic fan game is genuinely achievable, and the toolchain is more accessible than it has ever been.
GameMaker is the traditional choice, and it is free to download from YoYo Games. It is a good fit specifically because Sonic games are 2D platformers built on momentum and precise collision, and GameMaker handles that style of project well. Alternatives worth knowing about are Godot, Unity, and the purpose-built Sonic engines the community has produced over the years — some fan-made engines replicate the original Genesis physics almost exactly, which saves you a great deal of painful tuning.
You will need sprites. The honest advice here is to be careful: ripping sprites directly from Sega games and shipping them in a public release is a copyright problem, and Sega has taken fan projects down before. Many fan games sidestep this by drawing original characters in a Sonic-like style.
Work through tutorials for movement, tilemaps, and collision before you attempt anything ambitious. The single hardest part of a Sonic game is the feel of the movement — slope handling, acceleration curves, and the jump arc — and that is where most first projects fall apart. Get one character running around one level that feels right, then build outward.