I found the issue. The working option is the third one (including the kubectl command directly into the condition). The only additional thing I was missing is that I needed to add "sudo" before the command. I didn't have to do it within the VM because the user it was part of the suddoers.
PS. The first two were still getting stuck within the loop even though I added the sudo to the command.
echo "Waiting for the dev secret to be created ...... "
while [ $(sudo kubectl get secrets -n dev | grep "dev" | wc -l) -eq 0 ]
do
echo "inside dev secret loop ...... " >> /tmp/var.txt
sleep 1
done