The following commands are same as how to use rbenv on RaspberryPiOS.

sudo apt-get install rbenv
sudo apt remove ruby-build
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Then, you’ll be able to install the latest version..!

rbenv install 3.1.0
rbenv global 3.1.0
rbenv init # to see the install instruction.