I think your best bet is
st.markdown('# Section 1')
st.markdown('Lorem ipsum')
# As a text link
st.markdown('[Back to Top](#section-1)')
# As an html button (needs styling added)
st.markdown(''' <a target="_self" href="#section-1">
<button>
Back to Top
</button>
</a>''', unsafe_allow_html=True)
When you click a Streamlit button, it will by definition rerun the app. You can observe if you manually type in a url with the section anchor that the anchor goes away as the page finishes loading.