No, photographing military personnel in Pakistan is not allowed. It is considered a security-sensitive activity.
Strict prohibition
Military personnel, vehicles, and equipment are classified as sensitive and cannot be photographed under any circumstances.
What may happen
Security personnel may intervene immediately, ask questions, and require deletion of any images taken.
Public presence
Even when military personnel are visible in public spaces, photography remains restricted.
Common misunderstanding
Visibility does not equal permission. Military subjects are always treated as restricted for photography.