Sonic R has no official online mode. It is a 1997 Sega Saturn title, later included in some PC compilations, and it was built for split-screen local play at most.
The PC release is Windows-only and can be fussy on modern systems, so expect to spend time on compatibility settings or a community patch. Mac users are out of luck without emulation or a virtual machine.
If what you actually want is online Sonic racing, the series has better options. Later kart-style Sonic games and the free-to-play Sonic racing title that ran on mobile and PC were designed around online competition from the ground up.