Summary
If it is necessary to query features that have or don't have attachments, a definition query/filter can be created in ArcGIS Pro by the following basic steps:
- Create a new integer field.
- Open the Field Calculator.
- Use the Arcade expression.
- Apply a query.
Procedure
ArcGIS Pro:
- Open the layer's attribute table, and in the Field group, click Add, as shown in the next image.

- This opens the Fields window. Name the new field, and make sure the Data Type is Short or Long integer, as shown in the next image.

- Once this is done, click Save.

- Close the Fields window, go back to the attribute table, and click the Calculate button to open the Calculate Field window, as shown below.

- In Field Name, choose the field created in Step 2. Make sure that Arcade is selected as the Expression Type, and paste the expression "Count(Attachments($feature));" in the box. Verify that the expression is valid, click Apply, and close the Calculate Field window, as shown in the next image.

This process fills the new field with "1" if the record has an attachment, otherwise, the new field will show a "0", as shown in the next image.

- Create a definition query by right-clicking the layer in the Contents pane, and opening its Properties. Click the Definition Query tab. Create the expression, apply it, and click OK.

The same process can be done in ArcGIS Online, refer to this article: How To: Display only features with attachments in Attachment Viewer. Using the same Arcade expression, Count(Attachments($feature));, apply a query to get the features with attachments.