The best way to match GitHub's exact styling is to first render the Markdown as HTML in a browser (eg using markdown-viewer extension as mentioned above) and then print it to PDF. This ensures the closest possible visual match. The downside, though, is that many print-to-PDF methods embed text as images, making it unselectable.
I was actually browsing SO for ideas to improve my Markdown-to-PDF extension, and your question stood out. Right now, I’m working on implementing code block rendering with proper syntax highlighting, and I hope to solve this without relying on image-based exports. I’ll also definitely add a theme chooser to make styling more flexible.