I'll have a go at answering some of this, I think this is incomplete however.
Initial mega energy costs for Pokémon are 200 or 100. Once that particular Pokémon has evolved, it is unlocked and the cost of mega evolving further times is reduced to 40 or 20.
Each species has their own energy.
200 candy needed for first mega evolution, then 40;
Abomasnow, Amphardos, Blastoise, Charizard, Gengar, Gyarados, Houndoom, Venusaur.
Manetric added March 2021
100 candy needed, then 20
Beedrill, Pidgeot
Source:
1,
2
Only the Pokémon you evolved has the mega energy cost reduction, not all Pokémon of that species.
Source:
3
Walking with your buddy earns 5 Mega candy every km, but ONLY if that Pokémon has Mega evolved before. The mega energy is given when the buddy pokemon gives candy, this depends on the Pokémon's candy walk distance (1,3,5,20 km). If the distance is 3km, it will earn 15 Mega Energy every 3km but not before 3km is walked. 6 This means that it will require 9km to evolve the first list and 4km for Pidgeot or Beedrill. 7
Your buddy doesn’t have to be the same Pokémon that Mega Evolved, any Pokémon in the evolution line will earn Mega candy after you have Mega evolved once.
Mega Pokémon are active for 8 hours.
Mega Pokémon give you +1 candy to all Pokémon caught of the same type during the time it’s active.
Mega Pokémon will give +1 candy on the catch of a raid boss, regardless of your mega type, during the time it's active.
When in a raid or gym battle, when a Mega evolved Pokemon is on the field, all allied Pokemon's moves that share a type with the Mega evolved Pokemon will receive an attack boost until it leaves the field i.e. switches or faints.
Mega energy is gained when battling Mega evolved Pokémon in Mega raids. The speed at which you defeat the Mega raid is linked to how much energy you receive.
Mega energy is also gained in completing research tasks.
8
Mega evolution energy is capped at 999.
9
Additional energy gained from gyms in a set time:
https://www.reddit.com/r/TheSilphRoad/comments/miv2i5/what_are_the_breakpoints_for_mega_candies_when/gt6w4f5
Time to beat the boss (Amount of energy)
0s-0:29 (90 energy)
0:30-1:14 (80 energy)
1:15s-2:29 (70 energy)
2:30-3:44 (60 energy)
3:45-4:59 (50 energy)
Some speculation about rules:
Beedril is gaining energy from spinning gyms 4. This is at a rate of 5 energy given on average every 8 spins 5.