Use password window with script code in Terminal on macOS
You can use AppleScript to perform a sudo with a GUI.

do shell script "…" with administrator privileges


In ‘…’ insert a command to be executed as sudo, for example a path to your script.

To run this from Terminal, you can use osascript.

osascript -e 'do shell script "…" with administrator privileges'