Mr Mime used to work for Delia Ketchum and would follow all her commands. That means that Mr Mime also belonged to Ash because if Mr Mime doesn't fight for Ash then Delia would be sad so not to make her sad Mr Mime can help Ash win matches. Then why doesn't Ash use him in gym matches? He is a psychic pokemon and can be effective against a lot of pokemon. Then why Ash doesn't use him in battles? Also in this answer https://anime.stackexchange.com/a/56238/58903 user WonderCricket wrote that Ash doesn't have Psychic and Fairy pokemon but Ash does have Mr Mime which is a Psychic and Fairy type. So why don't many people count Mr Mime as a Ash pokemon?
Your premise of Mr. Mime being Ash's Pokemon because it so happens to obey Delia Ketchum is false.
First and foremost, Mr. Mime was never captured as a Pokemon. It simply decided to hang around Delia and help her out around the house.
By extension, because Mr. Mime is not a captured Pokemon, it does not belong to any specific trainer, and can choose to obey whomever it wishes.
Lastly, Mr. Mime only stays around Delia, and because Delia isn't out battling any gyms, Mr. Mime isn't being used in gym battles.
There are examples of uncaptured Pokemon, like Mimikyu and Jessie, which do get used in battles. I would say only recently did Mimikyu start to actually obey Jessie, but up until that point, it was Mimikyu's decision to obey or not.