Note regarding reopening votes: I've significantly improved the question based on the comments.
A passenger takes the flight: airport XXX in country A -> airport YYY in country B -> airport ZZZ in country C. The passenger is allowed by countries A, B, and C to exit/re-enter the airport YYY during their layover at airport YYY (which implies that country C is ok with the passenger leaving and re-entering the transit area in country B before flying+entering country C).
In that situation, can an airline prevent a passenger from boarding the plane during a layover because they left the transit area of airport YYY (e.g., to visit the nearby city)?
Note: This is not a theoretical question. A customer support employee from some airline was claiming that the passenger was not allowed to exit/re-enter the airport YYY during their layover at airport YYY, even though the passenger was satisfying all the regulations of countries A, B, and C to exit/re-enter the airport YYY. This made me wonder whether an airline can prevent a passenger from exiting/re-entering the airport during a layover and/or prevent the passenger from boarding the flight because they exited/re-entered airport YYY, or that simply the customer support employee was confused over the admittedly sometimes very confusing COVID-19-related traveling regulations.
Answer to comments:
The question is not vague and is not country-dependent: the question precisely asks whether an airline prevent a passenger from boarding the plane during a layover because they left and re-entered the transit area / the airport.