After trying the proposed solution and seeing that it still doesn't work.
The original code says to define MANPATH as explained in the man page, but when the man command reads the file, it append to MANPATH. So any command that exists in system man path (/usr/share/man, /usr/local/share/man) and was installed with brew, will show the man page inside of the system man path.
I started testing until I found a solution.
sudo mkdir -p /usr/local/etc/man.d
sudo tee /usr/local/etc/man.d/homebrew.man.conf <<'EOF' >/dev/null
manpath "/opt/homebrew/share/man:$manpath"
# Remove duplicated paths and extra colons.
manpath "$(printf %s "$manpath" | awk -v RS=: -v ORS= '!arr[$0]++ {if (NR>1 && length>0) print RS; print $0}')"
EOF
As you can see in the code it uses the variable manpath that after inspecting the source code of the man command, I have been able to verify that it is used to add in the MANPATH the specified paths.
As the same command creates a variable when it reads the configuration files, I have used it to modify directly the MANPATH just before it is defined.
Obviously with this method you can specify several paths but I do not recommend using it unless you are sure that it will not affect.
For example:
sudo tee /usr/local/etc/man.d/homebrew.man.conf <<'EOF' >/dev/null
manpath "/opt/homebrew/opt/curl/share/man:$manpath"
manpath "/opt/homebrew/share/man:$manpath"
# Remove duplicated paths and extra dots.
manpath "$(printf %s "$manpath" | awk -v RS=: -v ORS= '!arr[$0]++ {if (NR>1 && length>0) print RS; print $0}')"
EOF
It is important to establish a correct order, since the man, as far as I know, reads the first file it finds.
This happens on Sonoma and the Apple chip, I don't know if it happens with other OS and chip combinations.