Cankles-McJeggings in the game it’s passed via biting or by breathing in the spores. There are sections in the game where they wear gas masks inside areas that are infested with the zombies. Ellie doesnt need the gas mask because she is immune.
Although - the part in episode 2 where they show the fungus ‘speaking’ to the other infected in different parts of the city is a new addition; I dont recall that in the game (I’m referring to the part where the fungus grows and will wake up other infected elsewhere)