Hi Hasib,
Welcome to the forum!
While you can certainly tap into a potentiometer there are some specifications that you’d have to find before replacing one. @Robert93820 covers them really well here: 12 day project: ESP32 - LED controller - #11 by Robert93820
Also, note the resistance rating and the physical pin locations on a joystick as to whether you’d be able to swap them out.
There is also some risk in tapping into parts especially if it’s driving some expensive equipment, usually during/ after development there is a lot of testing that takes pleace proceed with caution!
Liam.