The main difference would be in the situation/context where each sentence sounds appropriate.
Let me start with the second sentence, instead of the first, for a good reason:
「野菜{やさい}の中{なか}で、どれがいちばん好{す}きですか。」
This sentence could be uttered (almost) out of the blue. It could be uttered in a conversation about food or vegetables in general. Both the speaker and listener know that the 「野菜」 includes all vegetables that exist.
The first sentence:
「どの野菜がいちばん好きですか。」
is a bit different.
It can be uttered in a conversations specifically about vegetables, but not in a conversation about food in general. At the very least, you need to have been talking about vegetables.
In other words, it could only be naturally uttered when both the speaker and listener's attention is already "focused" on either all vegetables or a already-selected group of vegetables.
Strictly speaking, native speakers would feel most comfortable uttering 「どの野菜がいちばん好きですか。」 in the latter case where a certain group of vegetables are either right in front of the listener or has already been discussed.
The problem, as usual, is that if you casually translate the two sentences, the important difference would not surface.
For the 「どの~~」 sentence, I might suggest that you use "Which one of these vegetables do you like the best?" because that is what it generally means to us native speakers. We are not choosing from all vegetables in the first place.