This is what I think the Pakistani position on any Iran-US conflict should be. Of course I expect our government to do nothing of the sort and do whatever Saudi/UAE tells it to do, or the US threatens it to do.
I think we should remain neutral. We should urge de-escalation and ask both sides to show restraint. We should demand that the UN and other international states intervene and prevent/stop a war.
My heart says we should stand by Iran as a fellow Muslim state, but my brain knows better than that. Iran doesn't consider us an ally, Iran doesn't consult us when fighting proxy wars across the Middle East and Iran doesn't seem to fussed about recruiting from Pakistan for it's proxy wars. They look after their national interest ahead of everything else and we must do the same. Brotherhood is not a one-way street.
We should refuse any US requests to use our airspace or territory to attack Iran (like Turkey did in the war against Iraq). We should continue to fence the border, but also be prepared to take in refugees in the very unlikely scenario that there is a ground invasion.
I expect this war will be limited to missile strikes and airstrikes, it'd all go very wrong for the USA if they ever considered a ground invasion of Iran. It's unwinnable. Iran mostly is ethnically the same (Persian) and mostly religiously the same (Shia). It doesn't have the social rifts that were exploited in Iraq/Syria/Afghanistan. Whatever the outcome, I expect we will have an Ayatollah in charge of Iran, or a government inspired by people like him - there will be no successful regime change. We need to be careful not to burn any bridges.
There is a slight possibility that Iranian retaliation might include attacks on US bases in Arab states. This might lead to the Gulf Arab states getting directly involved in the war. Even if they do, we must remain neutral and not get involved, not at any cost or for any price. We are at a stage where we are set to grow, we don't need to get involved in a regional war, especially siding with snakes. If anything we should pray the Ayatollahs kill some kings and princes and the kings and princes kill some Atayollahs. Win-win for us.
If a remote scenario where to occur where a ground invasion followed (this is incredibly unlikely), we should wait it out, see which side looks likely to win (in my case those loyal to the regime in Iran will come out on top) and covertly provide support through Afghanistan for whichever side comes out on top. We should maintain contact with both sides of the conflict, the to-be imposed puppet, as well as the current government.