Depends on what you consider "safe"... FDA safe? While it has not received FDA approval, both Melanotan One and Melanotan II have gone to human trials in about a dozen countries including Australia.
Most recently Melanotan One was approved in Italy for treatment of people that are allergic to the sun.
Safe as far as "it probably will not kill you"... Then yes, it probably is safe as literally thousands of bodybuilders and fitness enthusiasts have used it (and continue to use it).
Sitting in the direct sun continues to be more harmful as you're exposed to both UVA and UVB rays. The only protection against UVA is either pigment or a physical sunblock like Titanium Dioxide.