Pairing a Sonic fan character with a canon character is common practice in fan fiction, though the legality of the matter depends primarily on the owner of the copyright declining to press the issue. Derivative works are sometimes defended as parody or fair use, but more often copyright holders decline to pursue damages against fan fiction authors due to the boost in publicity provided and a lack of revenue lost or able to be recouped.
Sonic fan fiction in particular has a long history and active fandom with both canon and original characters. So long as the fan fiction author refrains from commercializing his work, copyright holders generally do not pursue legal action. Fan fiction authors often include disclaimers admitting the copyright of the work does not belong to them in the forewords of their stories.
While not a legal defense against accusations of copyright infringement, it's considered good etiquette in the wider fan fiction community to acknowledge the copyright holder and the original work or works. This disclaimer makes the fan fiction author's intent not to simply plagiarize or claim credit for another artist's work or works clear. The law defends fan fiction in a limited way through fair use and parody law, but in doing so the fan fiction author must prove that the fan work is "transformative" and substantially different from the original work or works.