You could also use pyenv to install and work with multiple versions of Python, without the burden of trying to build specific versions yourselves from source.
Any supported version that is requested for installation is built from source during the installation process, and this requires Python build dependencies (for Mac this includes zlib, ncurses, and a few others I think), but there is an installer which you can use (below), and I think it will preinstall these dependencies for you, in addition to pyenv:
curl https://pyenv.run | bash
I’m on a Mac, so I installed mine via Homebrew - I have never used the installer directly, but I believe it can also manage updates with pyenv update.
Once pyenv is installed, run this
pyenv versions
to list all installed versions - for you initially it should be your 3.10.12 installation (which should be labelled as "system", depending on what your PATH looks like).
Then you can install 3.11.9 with:
pyenv install "3.11.9"
I think 3.11.9 was only added very recently. Versions are installed to ~/.pyenv/versions, and your 3.11.9 bin should be located at:
~/.pyenv/versions/3.11.9/bin/python3.11
To get the latest supported versions keep your pyenv up-to-date - with the installer I think this would be with pyenv update. Supported versions can be listed with:
pyenv install --list