Although Sabrina dies in the Chilling Adventures of Sabrina series finale to rescue her friends and their loved ones from the Void, there are several ways in which Sabrina could show up in Riverdale. First and foremost, she could be resurrected. After all, death doesn't always last in the supernatural world.
However, it's more likely the episode takes place before her unfortunate, canonical demise. The vague sets and costumes of both shows and the appearance of Greendale high school bully Billy Marlin in Riverdale suggest Riverdale and CAOS are set in different, albeit close, timelines, making such a storyline not hard to pull off.
Another theory is that Riverdale's Sabrina is a different character, as there have been multiple versions of Sabrina. For example, in CAOS part three, the teen witch splits into two separate Sabrinas after using the magical powers of the Unholy Regalia to travel back in time to save her friends and family from the pagans. So theoretically, with the help of a bit of magic, something similar could happen that creates a new Sabrina.