The use of prepositions is not determined by general rules. It is a mess of special cases. But the rules about determiners do follow general rules.
Nouns that are proper names do not take determiners. Nouns that are mass nouns do not take determiners. Nouns that are countable nouns, are in the singular, and are not being used as proper names do require determiners. There is a more complex rule for plural countable nouns that is not relevant to your question.
"Sunlight" is an odd noun. If I go outside, can I count how many "sunlights" there are? No. That indicates "sunlight" can be considered a mass noun in some contexts. However, there are many sources of light, of which sunlight is one. So in other contexts, "sunlight" can be considered a countable noun. Thus, whether a determiner is needed depends on intended meaning in a specific context.
"Sun" is most definitely a countable noun. How many are there in this solar system? One. No doubt at all. Determiners apply to singular uses of "sun" unless it is being used as a proper name.
When we get to the prepositions, the rules are numerous and fuzzy and subject to many exceptions. "In" is generally used to specify a state of being surrounded rather than a direction. Sunlight envelops us outdoors (unless it is night or cloudy). So the "sound" of "in" seems "natural" to a native speaker. If we were surrounded by the sun, we would be fried to a crisp in an instant. The sun is distant and has a distinct direction associated with it; it is above us, and we are below it. So it "sounds natural" to say "under the sun." However, if "the sun" is being equated conceptually to "sunlight," it will then sound just as natural to say "in the sun" because there is no directionality being referenced.
Personally, I would say "dry in the sun." "Dry under the sun," "dry in the sunlight," and "dry in sunlight" sound a little odd to me. The first because the directionality implied by "under" is irrelevant in context; the second and third because heat rather than light is the actual drying agent. But I suspect that these judgments are mere personal preference. I certainly shallnotshall not say that the three variants I disfavor are ungrammatical.