If you're talking about the gym badges that Gary has that don't appear in the games, then there is no way to get them. There isn't a gym for them, and they were only in the anime.
If you want to know why he has these mysterious badges, then this or this
are questions that answer it.
Other than that, we don't know what these badges are, but we can't get them in the game, since they don't exist.