My name was drawn in this year's visa lottery. My girlfriend and I are talking about marriage. Same-sex marriage is legal in my country, and I've read that spouses can accompany DV lottery winners, but we're not yet married. Is it too late to get married and have my new wife get a green card along with me and come to the United States together?
No, it's not too late, assuming you can get married before your visa interview.
First off, you are correct that spouses, including same-sex ones, can accompany the winner of a diversity visa lottery to the United States, on a "derivative" visa.
Second, you don't have to have been married on the day of your lottery "win" to claim your same-sex spouse as a derivative.
The key will be that you are married before your immigrant visa or adjustment of status interview, indicate the appropriate information on the paperwork you fill out for that interview (you may need to amend what you've already submitted), and make clear that this isn't a marriage of convenience to get your new spouse a green card.
Also, (as you mentioned is the case), you will need to be married in a state or country that legally recognizes same-sex marriage.
You might need to provide not only a marriage certificate, but documentation of your good faith marriage; that is, of your real relationship and of the fact that you are planning to create a shared life together.
Be sure to act quickly no matter what you decide, however. You will need to obtain your diversity-based visa by the end of the fiscal year in which your name was drawn, or lose your chance at it, as discussed in these articles on diversity visas and green cards.