Tuning the hybridization and magnetic ground state of electron and hole doped CeOs2Al10: An x-ray spectroscopy study