The notion of generals fighting in hand-to-hand combat alongside their men is not as outlandish as it may seem. Alexander the Great had set the golden standard for personal bravery, charging at the head of his Companion cavalry time and again, getting injured on multiple occasions and narrowly escaping death on others. The kings and generals of the Hellenistic world followed his example, fighting in the front ranks as he had.
But Alexander did not exactly come out of a vacuum either: the Greek world had a long tradition of generals fighting in the front ranks of the hoplite phalanx. See u/Iphikrates' answer in this older thread
You asked about the Romans, though. And there the answer is a bit more ambiguous, but comes down on the "usually not" side of things.
Most of the time a Roman general would NOT be fighting in the front ranks. Instead, he would be just behind it, possibly mounted on a horse for better overview, with some body-guards to protect him. There, he could encourage his troops, mark out those who fought particularly bravely, send for reserves if needed, but he would be in much less personal danger.
For example, in Caesar's Gallic Wars, book II, battle the Aisne, he describes the following incident (emphasis mine):
There he [Caesar] beheld his troops hard driven, and the men of the Twelfth Legion, with their standards collected in one place, so closely packed that they hampered each other for fighting. All the centurions of the fourth cohort had been slain, and the standard-bearer likewise, and the standard was lost; almost all the centurions of the other cohorts were either wounded or killed, among them the chief centurion, Publius Sextius Baculus, bravest of the brave, who was overcome by many grievous wounds, so that he could no longer hold himself upright. The rest of the men were tiring, and some of the rearmost ranks, abandoning the fight, were retiring to avoid the missiles; the enemy were not ceasing to move upwards in front from the lower ground, and were pressing hard on either flank. The condition of affairs, as he saw, was critical indeed, and there was no support that could be sent up. Taking therefore a shield from a soldier of the rearmost ranks, as he himself was come thither without a shield, he went forward into the first line, and, calling on the centurions by name, and cheering on the rank and file, he bade them advance and extend the companies, that they might ply swords more easily. His coming brought hope to the troops and renewed their spirit; each man of his own accord, in sight of the commander-in‑chief, desperate as his own case might be, was fain to do his utmost.
Here is one of the very rare accounts of a Roman general advancing into combat. But note how even here Caesar does not mention fighting anybody: he takes a shield, not a weapon, and spends his time encouraging and reorganising his men. Caesar's work is always to be taken with a grain of salt, but this does tell us that he believes this is how a great Roman general ought to behave.
Other Roman generals might stay all the way in the back with the reserves. That might allow them a better overview of what was going on, and enable them to direct high-level reserves.
But there were always some generals and leaders who did try to emulate Alexander and lead by personal example. Rome had a tradition of heroic generalship in its ancient days. Livy is full of stories about Roman generals doing battle, and there was even a ceremony of dedicating the Spolia Opima, in which a Roman general who had defeated an enemy general in single-combat could lead a procession while bearing the enemy general's arms and armour (the aforementioned Spolia) to the Temple of Jupiter.
In historic times this was exceptionally rare, though. We mostly hear of an incident in Augustus' reign, where he denied a general (the grandson of the famous Crassus, no less) the chance to perform this ceremony.
But even in the later days of the empire we do get the occasional account of a general fighting. This is Ammianus' Marcellinus' account of the death of the emperor Julian in 363 AD:
it was reported to the emperor, who even then unarmed had gone forward to reconnoitre, that the rear guard had suddenly been attacked from behind. 3 Excited by the misfortune, he forgot his coat-of‑mail, and merely caught up a shield in the confusion;
[...]
Julianus, careless of his own safety, shouting and raising his hands tried to make it clear to his men that the enemy had fled in disorder, and, to rouse them to a still more furious pursuit, rushed boldly into the fight. His guards who had scattered in their alarm, were crying to him from all sides to get clear of the mass of fugitives, as dangerous as the fall of a badly built roof, when suddenly — no one knows whence — a cavalryman's spear grazed the skin of his arm, pierced his ribs, and lodged in the lower lobe of his liver.
Again, we see that the emphasis is on encouraging the men more than on fighting personally. This is emphasised again and again in our sources: soldiers would be inspired and reassured by seeing their generals join them.
This is mentioned for Romans and non-Romans. In an earlier passage from Ammianus:
suddenly there was heard the outcry of the German infantry, mingled with indignation, as they shouted with one accord that their princes ought to leave their horses and keep company with them, for fear that they, if anything adverse should occur, abandoning the wretched herd, would easily make shift to escape. On learning of this, Chonodomarius at once sprang down from his horse, and the rest, following his example, did the same without delay; for not one of them doubted that their side would be victorious.
Or in Tacitus, when describing the Roman general in the battle of Mons Graupius:
Then Agricola, fearing from the superior number of the enemy lest he should be obliged to fight as well on his flanks as in front, extended his ranks; and although this rendered his line of battle less firm, and several of his officers advised him to bring up the legions, yet, filled with hope, and resolute in danger, he dismissed his horse and took his station on foot before the colors.
So in summary:
No, most Roman generals would not be fighting in the front ranks with their men. They would either be just behind the front, to encourage their men, or much farther behind with the reserves.
You always did have a few brave and foolhardy leaders who joined the fight in person. As you might expect, this did not always end well. But having the general nearby did encourage the soldiers more.
Translations taken from
Caesar: http://penelope.uchicago.edu/Thayer/E/Roman/Texts/Caesar/Gallic_War/2*.html
Ammianus Marcellinus: http://penelope.uchicago.edu/Thayer/E/Roman/Texts/Ammian/25*.html