Honestly, just go to Ocean Beach. It's super easy and the sunsets there are always great. Can get a bit busy, but if you walk down a bit, it's quieter.
A hidden gem is the top of Corona Heights Park. It's a bit of a hike up, but the view is so worth it, and it’s usually not crowded at all. Perfect cityscape with the sunset.
Fort Funston! The cliffs are beautiful and there's always the chance to see hang gliders riding the wind as the sun goes down. Plus, it's dog-friendly!
Battery Spencer. It's technically in the Marin Headlands but still super close to SF. Not only do you get the bridge in the foreground, but it's also much quieter than the popular spots like Lands End or Twin Peaks.
If you're looking for a classic spot, Twin Peaks is unbeatable. The panoramic views of the city with the sun setting over the Pacific is quintessential SF. For fewer people, try Lands End, specifically at the labyrinth area. It's magical.