I'm probably reading this HN thread from a Pegasus-infected iPhone right now, and I have no way of knowing! The only commercial solution to detect Pegasus I know of is iMazing's Pegasus detection tool[0] which borrows techniques from Amnesty International's Mobile Verification Toolkit (MVT)[1] to detect Pegasus. Not sure how reliable it is though.
Anyway with something like Pegasus, all the forensic artifacts would be random and heavily mutated for each infected device, so it's not as easy as running a tool to detect its presence. Pegasus is known for doing anti-forensics under the hood.
[0] https://imazing.com/blog/detecting-pegasus-spyware-with-imaz...
[1] https://www.amnesty.org/en/latest/research/2021/07/forensic-...