The master nationality rule does not apply to sporting events. It applies to diplomatic protection.
Some countries take a dim view of multiple nationality. Many of these have laws that provide for the loss of the country's own nationality when someone obtains or even makes use of another nationality. I am not aware of any country that criminalizes the possession of another nationality, but it is certainly possible. But these considerations would arise as soon as country B learned that the athlete was representing country A on its national team, regardless of whether the athlete were competing against country B or in country B.
There are certainly many publicly known examples of Association Football players with multiple nationalities who play for the international team of one country. It should not be difficult to find examples of such a person competing both in and against another country whose nationality he or she holds. This should serve as a counterexample to disprove the question in the general case. Another place to look for counterexamples would be the Olympics.
A quick look at Wikipedia shows that Lionel Messi has both Spanish and Argentine nationality from birth. He scored a goal for Argentina against Spain, in Spain, on November 14, 2009.
Still, it's always possible that a given country would take steps against such an athlete. Whether that happens might depend on which other country is involved, if the two countries have tense relations.