Go to your layout and in the toolbar you can find toggle button.
If not you can achieve this by using toggle activity in nanoflow.
Just drag a button in layout and call a nanoflow.
In nanoflow use toggle side bar activity.
Hope my answer helps. Reach me out for any queries.
Are you using Atlas for your page layouts? If you are, this page in the documentation will explain how to setup the sidebar.