You really should have separate teams for each raid. A set of Machamps and Poliwraths will do well against Tyranitar, but not so well against Raikou, Gengar or Alakazam (not to mention Mewtwo). Think in terms of a team for raiding against this or that boss. If there's some spillover, that's fine, but separate teams for separate bosses makes the most sense.
How many level 30+ Machamp do you have to fight gyms?
Only started (regularly) fighting gyms recently. Machamp is by far the most utilised attacker ( as blissey, ttar, Snorlax, Chansey and even Lapras are all fixtures in the gym).
Have 2 level 30+ Machamp now and thinking whether I should power up a third one to go with raikuo (for Gary and vapareon), vaperon or execuggtor (for rhydon) and a Dragonite (for itself and as a generalist) as the starting VI?
I do have a double fighting poliwrath at level 30 though. But I think it is not as fast as machamp
EDIT: just to clarify, I do mean fighting gyms, not raid. I sometimes find 2 machamps are not enough to fight consecutive blissey, ttar, Snorlax then Chansey
Answers
You don't need more than two for gyms. No Blissey or anything will be tough enough to take down two big machamps.
Raids are another story. Tyranitar raids necessitate big machamps. I have a level 37.5 100% Machamp and a level 30 100% Machamp. The rest of my team is made up of weaker subpar Machamps that I haven't powered up, a double fighting level 30 98% Poliwrath for semianchoring, and a level 34.5 Vaporeon for anchoring.
Poliwrath makes a great Tyranitar tank counter as its defense is respectable and it resists ALL movesets of Tyranitar.
I got 4 powered up Machamp but I mostly use them for Tyranitar raids in addition to a double fighting Poliwrath and a C/PR Donphan. For regular gyms two Machamp are enough. Even for raiding Tyranitar your lineup should be fine when there are 5 or more players participating. For 4 players filling your last two spots with Vaporeon should be fine. For three players vs. Tyranitar you would probably have to invest in another Machamp or two and power them up further then lvl 30.
I have three powered up Machamps:
Level 33 (going to max out) 100% with C/DP
Level 31 82% with C/DP
Level 30 89% with C/Close Combat
I also have another 93% with KC/Submission that I've been on fence about using one or more Charge TMs and powering up. But so far, I haven't needed it, so my resources have been going elsewhere.
The only times the bottom two get used are in Ttar or Rhydon raids, with the former being very rare in my area. I use my hundo all the time when taking down Blisseys in gyms.
It really depends on your area.
If you are in a rural area, then you probably don't need any of them as the gym is likely to be low on motivation.
If you are in an intense area where gym turnover is high, then you probably need more than 3. Rolling the first Blissey for 3+ rounds and revive every 3rd round saves you time.
My personal estimation of "cost of Machamp" of the first round (full motivation and level 35+ defender):
Blissey: 0.8 Machamp
Snorlax: 0.4 Machamp
Chansey: 0.3 Machamp
Lapras: 0.3 Machamp
Rhydon: 0.3 Machamp
Tyranitar: (B+FB) 0.1 -(IT+Cr)0.3 Machamp
I've been lucky to catch two ok iv machops at lv 30, from TM they got C/CC on first try. I also have 2 very high IV Machamp (96&98) with C/DP that I have powered to 31. I like using the 2CC Machamps in the first round then switching over to the DP ones for rounds 2&3. It cuts down on time spent at the gym (no need to heal between rounds) and reduces the likelihood that golden razz come into play since I'm done taking down the gym before they even get a notification. It does take more potions, but I end up throwing more potions per day away than I ever use.
My closest gym is at a city park. It has a Chansey in there at 400cp (Valor), nobody else. It was closed overnight for 12 hours...but it has been there 19 hours...alone. 7hrs of nobody driving and throwing in. A fully coordinated and fully motivated gym just isn't typical, even in the active and busy parts of my city