There are some good plugins to help you do this. I recommend you to try the WP Sticky Sidebar plugin.
Follow the steps below if you want to give it try:
1. Install and Activate the “WP Sticky Sidebar” plugin.
2. After you Activated the plugin, the Plugin Settings screen should appear. If it’s not opened, open it from the Dashboard->Settings->WP Sticky Sidebar
3. Insert the #secondry into the Sticky Class text field, eventually insert the additional top margin per your wish.
4. Save the menu https://prnt.sc/rwu0m3
Refresh your webpage.
Your sidebar should be Sticky now.