Dharmani was unbeaten on 83 while Yuvraj made 52 with Punjab needing just 48 runs to overhaul UP's modest first innings total of 269.
At close, Punjab were 221 for seven.
A W Zaidi, 3 for 59, was the main wicket-taker for UP.
Earlier, resuming at the score of 239 for eight, the visitors added 30 to their total with overnight not out opener Rohit Parkash remaining unbeaten on 112.
The remaining two up batsmen -- Salabh Srivastava (0) and R P Singh (11) -- could not provide support to Rohit, whose 112 included 14 hits to the fence.
In their reply, Punjab kept losing wickets at regular intervals with Reetinder Sodhi (11) being the first to return to the pavilion, being out lbw to Srivastava when the total read 19. After the addition of four runs to the board, opener Ravneet Rickey (7) was bowled by Zaidi.
Dinesh Mongia (6) also failed to stay at the crease for long, being caught at short-leg by Elahi off Zaidi when the total was 43.
Yuvraj and Dharmani then got together to stem the rot, adding 71 runs for the fourth wicket.
Yuvraj, who had failed to impress in the two Tests that he played against Australia recently, showed signs of returning to form, hitting eight hits to the fence.