The story as recorded in 1 Sam 16 is quite clear. When the prophet Samuel arrived at Jesse's home, he met Jesse and all but the youngest of the sons, David who was out in the fields minding the sheep.
Thus, as the narrative is presented, David was absent when the "consecration" was done in V5. However, note the subtle distinction made. Let me quote 1 Sam 16:4, 5 -
4 So Samuel did what the LORD had said and went to Bethlehem. When the elders of the town met him, they trembled and asked, “Do you come
in peace?” 5 “In peace,” he replied. “I have come to sacrifice to
the LORD. Consecrate yourselves and come with me to the sacrifice.”
Then he consecrated Jesse and his sons and invited them to the
There were two groups of people present for this little local feast:
- The elders and officials of Bethlehem
- Jesse's family excluding David
Note that Samuel sanctified Jesse's family but everyone else sanctified themselves. However, David was not present for either.
Ultimately, David was consecrated after he was called (V11, 12) and he was anointed, set apart, for the sacred office of King of Israel (V13).