Legacy fenics is no longer developed. I believe it works with Python 3.10.
DOLFINx works with Python 3.10 and 3.11. See