The two examples you provided are very similar to the example we have here (if you want the add to cart button section to show/hide on scroll). You can customize the code in that example to fit your needs.
To make the button sticky you can:
Select the add to cart button
Scroll down to the CSS properties section in the styles tab
Apply these styles: position: sticky, top: 0, and z-index: 10.
This will make the button stick to the top of the page like this.
If you want the add to cart button to stick to the bottom instead, you can:
Select the add to cart button and give it position: fixed in the layout section of the styles tab
While in the layout section, give the button a bottom, left, and right value of 0.
Give the button a z-index value if needed so it sits on top of your page content.
You can definitely make this specific to product pages, if you want to add this section to your existing product pages, you can add a custom section. You can also build out a new product page in Builder that includes this section. The add-to-cart button and variants will work as long as these elements are wrapped in a product box block.