Seems dynamically show or hide sidebar according to tab selection is not supported at the moment. Found this Note:
All content within every tab is computed and sent to the frontend, regardless of which tab is selected. Tabs do not currently support conditional rendering. If you have a slow-loading tab, consider using a widget like st.segmented_control to conditionally render content instead.
https://docs.streamlit.io/develop/api-reference/layout/st.tabs