Azhar's average takes a drop every time he is chasing a score from behind (as per latest, 2nd innings average is around 24 runs lower than 1st innings, almost identical drop in 4th compared to 3rd). For a Test match, 3rd innings is often much easier than 2nd innings because you are setting a target and batting without pressure of chasing one. Which indicates, he is not a pressure player.
And, I can explain the reason with his batting strengths (or weakness). Azhar is the perfect example of stroke less wonder - virtually a batsman with zero shot making ability unless it's a poor ball (long hop or pitched up half volley). His batting strength is his tenacity - ability to stick around without scoring (in 90s, 3 maidens in a row & most PAK batsmen would go for a low % shot - Azhar can wait for 3 hours), and his value for wicket - he hardly gets out to a poor ball, because he hardly goes after it.
This batting strategy (or limitation) is workable when he is batting first (or 3rd), without any score board pressure and without the stress of chasing a target. Because, he can take all his time and keep holding one end, without bothering the end result. But, when he is batting 2nd, stagnant score board puts pressure, as the target isn't reducing much, which doesn't put bowling side in panic - they can keep things tight and wait for a slow death. This puts extreme pressure on Azhar and eventually he has to come out of comfort zone - that's playing shots.
I never saw his stats by innings, but I predicted something similar, because I can't recall much of him in 4th innings. On contrary, YK has one of the best 4th (2nd) innings stats and he has played some remarkable knocks in last innings. If anyone can recall, one feature of YK's batting is that he is probably fastest scorer in his 4th innings - always busy, always trying to score and takes every chance of hitting a boundary, be it a bit risky. In recent times, I can recall PAK winning 2 Tests chasing tight targets - one in SRL (YK 170+*) & this latest one. Common in both cases is that Azhar Ali got out quickly, and PAK's RR was highest in the 4th innings - someone (here Imam, there YK), went after the bowling and kept official scorer busy. On contrary, at Hamilton, Azhar took 4 hours for his 50, then got out and the floodgate opened to sweep everything out in a session.
In recent times, PAK did a miracle - lost 2-0 to that SRL at UAE; that too SRL could have enforced the follow on in 2nd Test, but they batted 2nd time & got blown away, which made the game look close, statistically. In both games, PAK batted 2nd and Azhar actually scored good amount - and PAK lost chasing reasonable (once tiny) targets. More than 4th innings, damage was done in 2nd innings of the game, if one notices Azhar's scoring - both times, he had a long outing. His 225+ balls 1st innings at Abu Dhabi was 2nd most damaging thing in the game (1st one was 3+1 bowling combination, which Arthur/Sarfraz can explain better). Apart from that 70 against SRL, when Angelo was defending less that 6 asking rate, with probably 9 men on line, I can't recall a single AA knock of any significance in 4th innings; business usual, his high scores across 4 innings, often ends in defeats, because he never cashes on a good start through his scoring rate.
Batting in Test cricket is a bit different - most people think it's about surviving as there is unlimited time (no over restriction). Actually, it's totally opposite - scoring rate is the most important thing in Test, as the options are open and batsman will get out eventually, better to make hay when sun is shining. When the game is limited by balls (fixed number of overs, be 50 or 20), going after the bowling isn't a choice, rather obligation - one has to bat according to asking rate. But, in Test cricket, one has the option to play positively or defensively - therefore in Test, best batsmen are not judged by average only, rather the impact they create.
For example, in 1950s-60s, the highest average of an English batsman was Barrington's almost 59 for around 7K runs - how many can recall him and how many could recall his 4 other contemporary countrymen - Graveny, Dexter, May & Cowdrey, with career average 10-12 lower? For that matter, how many, 2 other batsmen of same era - Rohan Kanhai & Neil Hervey with average below 48?
How much he could have scored, I can't tell, could have been a duck as well - but one thing I can say how Viv would have approached that 160 against Ireland. Murtagh was their best bowler and he had to have a great game with new ball, to win it - Viv would have come and immediately gone after the main man - Murtagh; could have got out for a duck, but a 35 ball 38 and the game ends there, though it doesn't help Viv's average (which was as ordinary as it can be, for the sheer ability - 50.23, half of Bradman!!!) that's why he was Viv Richards, and here I am writing that in both cases, PAK's chase was made easy that Azhar got out quickly.
Nothing personal - just sharing my observation: Azhar Ali should never, never bat at 3//.