Working in a startup will brand you as a startup person and help you meet VCs which may make it easier to raise. It'll also show you the problems that that particular startup faces and give you n=1 degree of pattern matching. On the flip side, something like YC can give you the same benefit or just shipping a for-profit side project on the side. Additionally, given how poorly run most startups are today, I'd posit that you're actually in more danger of learning the wrong lessons than the right lessons by joining a startup. At the end of the day, the truth is likely to be Peter Thiel's observation that joining the right, highly successful, high growth startup as a very early employee is a great way to learn exactly 1 method of starting a successful company--the way that company did it. But if the startup you join isn't that rocketship, you've only learned how to (or how not to) achieve that particular path of failure or mediocrity.
Not particularly great advice though, because then the challenge becomes identify those startups. And if you could do that reliably, I'd suggest you switch careers into VC instead :)