See for example Is this prompt for iCloud credentials legit?, ICloud Password prompt, and other similar questions, where a dialog pops up in MacOS asking for the user's password.
As a user, I presume it would not be difficult for a malicious software to simulate this dialog and request the password.
So, when I see a dialog asking for my password, is there a way to determine whether the dialog is legitimate (i.e., from macOS / Apple) or not?