My name was drawn in this year's diversity visa lottery. My girlfriend and I are talking about marriage. This will be a same-sex marriage, which is legal in my country. I've read that spouses can accompany DV lottery winners, but we are 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. Also, you are correct that spouses, including same-sex ones, can accompany the winner of a diversity visa lottery to the United States, on what's called a "derivative" visa.
You do not 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, that you indicate the appropriate information on the paperwork you fill out for that interview (you might need to amend what you've already submitted), and that you make clear that this isn't a marriage of convenience to get your new spouse a green card.
Also, (as you mentioned is true on your 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. (There's a lot of suspicion of marriage fraud among U.S. immigration authorities.)
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. See in particular, Spouses and Children of Visa Lottery Applicants Can Qualify for Derivative Green Cards.
And consult in attorney if you have questions about the process or would like assistance with the paperwork and with ensuring that everything gets done as soon as possible.