Is it possible to add servers to a group if a service is present on that server using dynamic query? So if on a Linux server if CUPS service exists, it will automatically be added to a group
I'm checking now, but it would rely on you monitoring the CUPS service on said hosts.
From the looks of it, the SolarWinds Platform does not (at present). I don't think there's a way "out of the box" to do this because the Dynamic Query in the Group Builder doesn't have the logic to go beyond the "scope" of the Target Object (in this case "Nodes'). This would be an excellent thing to add to the SolarWinds Observability Self-Hosted (formerly known as Hybrid Cloud Observability) Feature Requests - "Allow Group Dynamic Query Builder to extend beyond Object." (I'd like an "Advanced (SWQL)" option, personally)
However, you could do something clever with custom properties (which is how I used to do this years ago and it still works).
Is it elegant? No. Goes it work. Yes.