Generally, no. Playing a multiplayer match is not itself a vector for malware. The large, established gaming services run solid security screening that filters out malicious programs and spam before they reach players.
The distinction worth keeping in mind is between playing a game and everything surrounding it. The match itself is a fairly locked-down exchange of game state. The risk creeps in through the periphery: files downloaded from unofficial sites, "cheat" executables that ask you to disable your antivirus, cracked launchers, and links pasted into chat by strangers.
So the accurate answer is that the act of playing is safe, while the ecosystem around some games is not. Stick to official clients and platforms, be sceptical of anything that requires elevated permissions to work, and you can play online without worrying about your machine.