I am not a lawyer so this is not legal advice (you'd have to talk to a real lawyer for that), and the law varies around the world. But on the whole I think you are OK so long as you do not use any of the exact same assets (artwork, audio, etc.) or code, since that is all covered by copyright, nor the same name, since that may be a trademark.
For example you cannot use the exact Sonic sprite developed by Sega (that is their copyright), nor the name "Sonic" (that is their trademark). But you can make your own game involving a fast hedgehog that is based entirely on your own original assets (or someone else's original assets that you have permission to use), that also uses a different name.
If you draw original materials that look similar to Sonic, that is a grey area and probably not OK since there can be somewhat loose rules about likeness. So to be on the safe side, don't try to make it look like any existing games, just keep things original.