If Apshai is correct in his formula, use int(random(1,7)) + int(random(1,7)) to indeed generate a result for 2 to 12 only made of integers.
The int() allows to make sure only integers are returned and the max range value in the random() function is never reached, so if you want a result at some point to actually be 6, go for a max range of 7.
I think I remember a long time ago the very same subject being discussed in the forums already (like back in 2012/2011).
I can't remember exactly the formula given in the end, and I don't remember if there wasn't a recommendation to actually use round(), ceil() or int().
I can't seem to find back the discussion though, I hope this helps you nonetheless.