Is there any primary evidence of what happened? Would the soldier relieve himself and then catch up with his comrades?
In case of a battle, would they be able to sit it out due to illness or they'd be accused of cowardice?
Thank you.
He would hold it until he had an opportunity to take care of it, exactly like humans have been doing for thousands of years. The legions were made up of human beings, after all. If it was an emergency, like he ate some undercooked rabbit the night before, then he would just have to sort it out as best as he could and catch up if possible. There is no primary evidence of soldiers relieving themselves to my knowledge, no, though in Petronius' Satyricon, a soldier diverts from the path to relieve himself among some tombs. He then turns into a wolf, though, so there is a bit more going on in that story, and he wasn't in formation at the time.
In the case of serious illness or injury, in a typical Roman legionary situation (in any time period), he would either push on with the help of his contubernium (his tent-mates, his squad) or he would tell his centurion that he was in distress and would probably be sent back to the camp, or would be relegated to a secondary role. There isn't very good evidence for the specifics in any time period, unfortunately, but such a question was hazy even 2000 years later, in a relatively modern setting like World War 2. When soldiers (on either side) were injured in the field, they could either go back to the rear (if even possible) or they could do the best they could. "Do the best you can" and "figure it out" is a pretty common litany for soldiers in any time period. Many severely injured soldiers were later ostracized by their mates upon their return to the lines, because they had been absent from this or that traumatizing event, and others who were only lightly injured and stayed on the line were valorized for staying. It was obviously unfair and extremely arbitrary, and I strongly suspect it was a nearly identical situation for the legionnaires.