Since the last update you can now obtain a badge for a specific gym when you spin its photo disc. It is then possible to level it up by defending it, feeding the Pokemons from your team with berries or attacking it if another team is controlling it. Leveling the badges up apparently awards you with a new badge rarity, going from Bronze to Gold, as you can see from the picture below.
Does the rarity of a badge affect the gym it's linked to? For instance, can you get additional loots, or will your own Pokemon's motivation decrease more slowly?