Yes. It has to do with the ratio of their frequencies. Essentially, the smaller the numbers involved the better.
The perfect unison, with a 1:1 ratio (e.g., C played with the same C), has perfect consonance. C to the next G has a 2:3 ratio; the perfect fifth is the next most consonant. The minor second (e.g., C to C#) is the most dissonant in Western scales with a frequency ratio of 15:16.
What this represents is how often the sound waves "match up". Every third cycle of a C matches with every second cycle of a G, and vice versa; i.e., the peaks of the waves occur at the same time every two cycles (or three cycles, depending on which note you choose as the base). This is often! So overall, your ear perceives the sounds as being in sync and melodious. In contrast, waves that match up infrequently, such as the minor second with only the 15th (16th) cycle matching, are largely out of sync and therefore dissonant.
The mind is strange, and what one perceives as dissonance is not necessarily what another would perceive as dissonance. That said, the closest you'll get to an absolute, objective measure is the base 2 logarithm of the Least Common Multiple of the the sides of the ratio. E.g.:
lg(LCM(15, 16)) = lg(240) ~= 7.9
This is about 3 times more than
lg(LCM(2, 3)) = lg(6) ~= 2.6
Neatly,
lg(LCM(1, 1)) = lg(1) = 0
so this also reflects the fact that the perfect unison has no dissonance. Interestingly, Euler seemed to think the LCM was the way to do this as well1.
(Note that LCM(x, y) = x*y
for fully reduced ratios; e.g., 2:3 rather than 4:6.)
[1]: Knobloch, Eberhard (2008). Euler Transgressing Limits: The Infinite and Music Theory. Quaderns d’Història de l’Enginyeria, IX, 9-24. Available online: http://upcommons.upc.edu/revistes/bitstream/2099/8052/1/article2.pdf