Correct, the version of ruby pre-installed with Sonoma even is a mere ruby 2.6.10. Hardly capable to run the latest Jekyll.
As far as maintaining a user-installed version of ruby separate from the system, I recommend a package manager, which requires pretty extensive use of the command line. Getting somewhat familiar with homebrew is a must, however as great as it is, lacks some of the advanced capabilities required to slot multiple installations of ruby into a user’s home directory and manage slotted install gems, etc al while managing updates to ruby.
I use a package manager called asdf, whcih not only supports ruby, but also allows for more complicated web projects that require node.js and/or other frameworks/libraries.
Furthermore, the build errors you encountered, sort of indicate you might not have installed the Xcode command line tools which is not installed by default. This allows macOS to use the build tools which are traditionally part of a linux desktop os… in any event here’s a nice guide here with instructions on how to install homebrew, the command line tools, and of course ruby: Check Mac Version · Update macOS · Mac Install Guide
Hope this helps!