Supremum of a product measurable function...

Here is an example in which the resulting function $g$ is nonmeasurable, but only slightly so:

We let $X=Y=[0,1]$, endowed with the Borel $\sigma$-algebra. We let $A\subseteq [0,1]^2$ be a Borel set such that the projection $\pi_X(A)$ to the first coordinate is not Borel (and hence only analytic) and $f=1_A$ be the indicator function of $A$. Then $g$ is the indicator function of $\pi_X(A)$ and hence not Borel measurable. However, $g$ will be measurable with respect to every complete probability measure on $X$.

This problem is actually a typical example for why one uses analytic sets in optimization problems. For a nice introduction, see Some Measurability Results for Extrema of Random Functions over Random Sets by Stinchcombe and White.