Export UVs to .png - output with alpha is different when launched from command line
I did exactly the same thing you did, exported the UVs from the Suzanne.

Though i did export it twice with once default opacity 0.25 and once with it set to 1 as you use in the script.

The code is taken from the Scripting Tab bottom left window. Here we can see as in the picture below, the default 0.25 function framed red(default value is optional and does not show up in the function used), the value of 1 (is not default, so the value shows up as parameter) in green:



bpy.ops.uv.export_layout(filepath="..\\Suzanne.png", size=(1024, 1024))


When compared to the one you use, there is a significant difference. Opacity by default when using the menu is 0.25, while in your script you use "opacity=1".



Using:

bpy.ops.uv.export_layout(filepath="..\\Suzanne1.png", size=(1024, 1024), opacity=0.25)


i got the exact same image as i got from when i used the menu function without changing the opacity.

So i would suggest you try your script with the adjustment of the opacity to "0.25".
That should do the trick.