The set of maps in $L^0(X,\mu,Y)$ with countable range is always Borel, and the way to see it is to correctly reformulate the question: we are looking at the set of elements  $f\in L^0(X,\mu,Y)$ such that the pushforward measure $f_*\mu$ is completely atomic. 

Now, if we let $(A_s)_{s\in \mathbb N^{<\mathbb N}}$ be a Lusin scheme on $Y$ (for the definition of a Lusin scheme see *Classical descriptive set theory* by Kechris, def. 7.5) , we see that the measure $f_*\mu$ is completely atomic iff as $\epsilon$ tends to $0$, the quantity $$\lim_{n\in\mathbb N}\sum_{|s|=n, \mu(f^{-1}(A_s))\geq \epsilon}\mu(f^{-1}(A_s))$$
converges to one (at each stage $n$ we compute the measure the reunion of the elements of our countable partition $(A_s)_{|s|=n}$ which have measure greater than $\geq\epsilon$, so that at $\epsilon$ fixed the limit we get as $n\to \infty$ is the measure of the set of atoms which have measure $\geq \epsilon$), which is a Borel condition.  Not that the same argument shows that the set of continuous probability measures is Borel (exercise 17.37 of loc.cit.): it is the set of measures for which the above quantity  equals zero for all $\epsilon>0$.