Yu-Shiba-Rusinov bound states studied by tuning the electron density at the Fermi energy