Mobile Verification Toolkit (MVT) is a collection of utilities to simplify and automate the process of gathering forensic traces helpful to identify a potential compromise of Android and iOS devices.
In addition to pegasus it also detects:
- NSO Group's Pegasus (more info from Amnesty Tech).
- Predator from Intellexa (formerly Cytrox) (more info from Citizen Lab)
- KingsPawn from QuaDreams (more info from Citizen Lab)
- Operation Triangulation from an unknown source (more information from Kaspersky)
https://docs.mvt.re/en/latest/
If you have no experience in using forensic tools and command line, these tools are included in the "iMazing" software for iPhone for free, for android I don't know if there is any similar tool.