Yes you can win and keep the money if you are of legal age.
…..and good luck ?
If you win that kind of money you can buy citizenship or a green card. I believe if you invest $500K in an American company, you can have whatever you want.
As for legally playing the lottery, there are no restrictions. As long as you are here legally, you can claim. They will hammer you for the biggest tax bill they possibly can, and give you what’s left.
But the odds of winning are worse than 150m-1, so the odds of you winning before your visa expires is incredibly slim.