Fortunately there is a way..
Download this Button Mapper , grant the accessibility permission then click on add a button then press the button to record it and then set the function you want! Simple as that.
Remember to turn off battery optimization for Button Mapper app because if the app is paused by the battery optimization then no hardware buttons will work (touch screen will work). You’ll have to go to settings and kill the Button Mapper app to get hardware buttons working again.
This is the only way to change the button function without root.