Hello,
You can do what you want with CSS code or you can use a plugin.
Here are a few resources to get you started:
http://www.wpbeginner.com/plugins/how-to-create-a-sticky-floating-sidebar-widget-in-wordpress/
https://www.webhostingsecretrevealed.net/blog/wordpress-blog/how-to-add-a-floating-sidebar-to-a-wordpress-site/
https://css-tricks.com/scrollfollow-sidebar/