As far as I can tell, the only way to disable it is to have the sidebar always on
The WebKit based Orion Browser has a setting to disable “Auto-show sidebar in full screen”, but it doesn’t seem to be working in Safari 17.3.1, so I doubt there is a way to disable it in window mode.
defaults read com.kagi.kagimacOS AutoShowSidebarInFullScreen
defaults write com.apple.safari AutoShowSidebarInFullScreen -bool NO
defaults write com.apple.safari AutoShowSidebarInFullScreen -bool YES
defaults write com.apple.safari AutoShowSidebarInFullScreen -bool NO
defaults delete com.apple.safari AutoShowSidebarInFullScreen
I’ve also tried AutoShowSidebar
defaults write com.apple.safari AutoShowSidebar -bool NO
defaults delete com.apple.safari AutoShowSidebar