Let $M$ be a compact riemannian manifold equipped with a geodesic distance and let $\mathcal{B}(M)$ be the borel sigma algebra generated by the geodesic distance. Let $(\Omega,\mathcal{F},\mathbb{P})$ be a probability space that arises from a compact metric space $(\Omega,d)$ and $\mathcal{F}$ is the borel sigma algebra. Let $\tilde{\Omega}$ be a countable dense subset of $\Omega$.


We would like to answer to the following question:
Let:
$$f \colon (\tilde{\Omega},\mathcal{F}\_{\rvert\tilde{\Omega}}) \to (M,\mathcal{B}(M))$$
be a measurable function.
Is it possible to construct a function
$$g \colon (\Omega,\mathcal{F}) \to (M,\mathcal{B}(M)) $$
with the property that $g$ is measurable, $g\_{\rvert\tilde{\Omega}}= f$ and,
if $\omega \in \Omega\setminus \tilde{\Omega}$, then


$$g(\omega)= \lim\_{n \to \infty}f(\omega\_n) $$


for a sequence $ \{\omega\_n\}\_{n \in \mathbb{N}} \subset \tilde{\Omega}$ such that $\omega\_n \to \omega$ as $n \to \infty$?



Extension of measurable function from dense subset
$\newcommand\R{\mathbb R}\newcommand\om\omega\newcommand\Om\Omega\newcommand\tom{{\tilde\omega}}\newcommand\tOm{\tilde\Omega}\newcommand{\ep}{\varepsilon}\newcommand{\de}{\delta}\newcommand{\vpi}{\varphi}\newcommand\ol\overline\newcommand{\N}{\mathbb N}\newcommand{\Q}{\mathbb Q}$Take any $m\in\text{Im}(f)$ and then let
$$g(\om):=
\begin{cases}
f(\om)&\text{ if }\om\in\tOm, \\ 
m&\text{ if }\om\in\Om\setminus\tOm. 
\end{cases}$$
The $g$ will have the desired properties.




---


The OP has changed the question, thus invalidating the answer above.


The answer to the changed question is still yes, but the construction is much more complicated.


Since the manifold $M$ is compact, it has a finite [atlas](https://en.wikipedia.org/wiki/Differentiable_manifold#Atlases) $A:=\{(U\_i,\vpi\_i)\colon i\in[k]\}$, where $[k]:=\{i\in\N\colon i\le k\}$, with bounded images $\vpi\_i(U\_i)$ of the $U\_i$'s. Without loss of generality (wlog), $A$ is a refinement of another atlas $\{(V\_i,\psi\_i)\colon i\in[k]\}$ of $M$ in the sense that $\ol{U\_i}\subseteq V\_i$ and $\vpi\_i=\psi\_i|\_{U\_i}$ for all $i$, where $\ol S$ denotes the closure of a set $S$ and $|\_S$ denotes the restriction to $S$.


For each $i\in[k]$, let
\begin{equation}
 \hat\Om\_i:=f^{-1}(U\_i), \quad 
 \Om\_i:=\ol{\hat\Om\_i}\setminus\bigcup\_{j\in[k-1]}\ol{\hat\Om\_j}, \quad 
 \tOm\_i:=\hat\Om\_i\cap\Om\_i. 
\end{equation}
Then
\begin{equation}
 \Om=\bigcup\_{i\in[k]}\Om\_i 
\end{equation}
(because $M=\bigcup\_{i\in[k]}U\_i$, whence $\tOm=\bigcup\_{i\in[k]}\hat\Om\_i$, whence $\Om=\ol\tOm=\ol{\bigcup\_{i\in[k]}\hat\Om\_i}=\bigcup\_{i\in[k]}\ol{\hat\Om\_i}=\bigcup\_{i\in[k]}\Om\_i$);


* the $\Om\_i$'s are pairwise disjoint and measurable;
* $\tOm\_i$ is countable and dense in $\Om\_i$ for each $i$ (because the $\ol{\hat\Om\_i}$'s are closed sets);
* $f(\tOm\_i)\subseteq U\_i$ for each $i$.


So, it suffices to construct the function $g$ locally -- that is, separately on each $\Om\_i$. So, to simplify notations in what follows, fix any $i\in[k]$ and let


* $U:=U\_i$, $\vpi:=\vpi\_i$, and $\psi:=\psi\_i$.
* Also, re-define $\Om$ and $\tOm$ by letting them, respectively, denote $\Om\_i$ and $\tOm\_i$, from now on.


In other words, we are going to omit the subscript ${}\_i$ everywhere in what follows.


Let $n$ denote the dimension of the manifold $M$, so that
\begin{equation}
 \vpi(m)=(\vpi^1(m),\dots,\vpi^n(m))\in\R^n
\end{equation}
for some real-valued functions $\vpi^1,\dots,\vpi^n$ and all $m\in U$.
For $j\in[n]$, let
\begin{equation}
 h\_j:=\vpi^j\circ f,\quad\text{so that }h\_j\colon\tOm\to\R. 
\end{equation}


Take any real $\ep>0$. For each $\om\in\Om$, let  

\begin{equation}
 H\_\ep(\om):=\vpi(f(\tOm\cap B\_\om(\ep)))
 =\{h(\tom)\colon\tom\in\tOm\cap B\_\om(\ep)\},
\end{equation}
where
\begin{equation}
 h(\tom):=\vpi(f(\tom))=(h\_1(\tom),\dots,h\_n(\tom))
\end{equation}
and
\begin{equation}
 B\_\om(\ep):=\{\tau\in\Om\colon d(\tau,\om)<\ep\}. 
\end{equation}
Since the map $\vpi$ is continuous and $f(\tOm\cap B\_\om(\ep))\subseteq\ol U\subseteq M$, the set $\ol{H\_\ep(\om)}$ is a compact subset of $\R^n$. So, there is a unique maximum, say
\begin{equation}
 \ol h\_\ep(\om)=(\ol h\_{1,\ep}(\om),\dots,\ol h\_{n,\ep}(\om))\in\R^n, 
\end{equation}
of the set $\ol{H\_\ep(\om)}$ with respect to the ([total/linear](https://en.wikipedia.org/wiki/Total_order)) [lexicographic order](https://en.wikipedia.org/wiki/Lexicographic_order).


Note that for any real $c\_1$
\begin{equation}
\begin{aligned}
 &\ol h\_{1,\ep}(\om)\le c\_1 \\ 
 &\iff \\ 
 &\forall\tom\in\tOm\quad \tom\in B\_\om(\ep)\implies h\_1(\tom)\le c\_1,
\end{aligned}
\end{equation}
which can be rewritten as
\begin{equation}
\begin{aligned}
 &\ol h\_{1,\ep}(\om)\le c\_1 \\ 
 &\iff \\ 
 &\forall\tom\in\tOm\quad \om\in B\_\tom(\ep)\implies h\_1(\tom)\le c\_1,
\end{aligned}
\end{equation}
Letting $\Q\_{++}:=\Q\cap(0,\infty)$,
by induction on $n$ one can show that for $n\ge2$ and any real $c\_1,\dots,c\_n$
\begin{align\*}
 &\ol h\_{1,\ep}(\om)\le c\_1\ \&\ \cdots\ \&\ \ol h\_{n,\ep}(\om)\le c\_n \\ 
 &\iff \\ 
& \begin{aligned}
& \ol h\_{1,\ep}(\om)\le c\_1\ \&\ \cdots\ \&\ \ol h\_{n-1,\ep}(\om)\le c\_{n-1} \\ 
&\&\ \forall\de\_n\in\Q\_{++}\ \exists \de\_1,\dots,\de\_{n-1}\in\Q\_{++}\ 
 \forall\tom\in\tOm\quad \\ 
 &\quad\ \om\in B\_\tom(\ep) \\ 
 &\quad\ \implies 
 (h\_1(\tom)\ge c\_1-\de\_1\ \&\ \cdots\ \&\ h\_{n-1}(\tom)\ge c\_{n-1}-\de\_{n-1} \\ 
&\qquad\qquad \implies
 h\_n(\tom)\le c\_n+\de\_n). 
\end{aligned}
\end{align\*}
Therefore and because the balls $B\_\tom(\ep)$ are measurable whereas the sets $\Q\_{++}$ and $\tOm$ are countable, we conclude that the $\R^n$-valued function $\ol h\_\ep$ is measurable.


Moreover, since the set $H\_\ep(\om)$ is nondecreasing in $\ep$, so is the maximum $\ol h\_\ep(\om)$ of the set $\ol{H\_\ep(\om)}$. So, there is a pointwise limit $\ol h$ of $\ol h\_\ep$: for each $\om\in\Om$,
\begin{equation}
 \ol h(\om):=\lim\_{\ep\downarrow0}\ol h\_\ep(\om) 
\end{equation}
and, hence, by the continuity of the map $\psi^{-1}$,
\begin{equation}
 g(\om):=\psi^{-1}(\ol h(\om))=\lim\_{\ep\downarrow0}\psi^{-1}(\ol h\_\ep(\om)). 
\end{equation}


The function $\ol h$ is measurable, as the pointwise limit of the measurable functions $\ol h\_\ep$. Also, the continuous map $\psi^{-1}$ is measurable. So, $g=\psi^{-1}\circ \ol h$ is measurable.


The maximum $\ol h\_\ep(\om)$ of the set $\ol{H\_\ep(\om)}$ is of course in $\ol{H\_\ep(\om)}$ and hence $\ol h\_\ep(\om)=\lim\_{r\to\infty}h(\tom\_{\ep,\om,r})$ -- for each real $\ep>0$, each $\om\in\Om$, and some sequence $(\tom\_{\ep,\om,r})\_{r\in\N}$ in $\tOm\cap B\_\om(\ep)$.


Since $\psi^{-1}$ is continuous and $\psi^{-1}(h(\tom))=f(\tom)$ for all $\tom\in\tOm$, we have
\begin{equation}
 g(\om)=\lim\_{\ep\downarrow0}\psi^{-1}(\lim\_{r\to\infty}h(\tom\_{\ep,\om,r}))
 =\lim\_{\ep\downarrow0}\lim\_{r\to\infty}\psi^{-1}(h(\tom\_{\ep,\om,r}))
 =\lim\_{\ep\downarrow0}\lim\_{r\to\infty}f(\tom\_{\ep,\om,r}). 
\end{equation}
So, for each $\om\in\Om$ there is a sequence $(r\_t(\om))\_{t\in\N}$ in $\N$ such that
\begin{equation}
 g(\om)
 =\lim\_{t\to\infty}f(\tom\_{1/t,\om,r\_t(\om)}). 
\end{equation}
Moreover, $\tom\_{1/t,\om,r\_t(\om)}\in B\_\om(1/t)$ and hence $\tom\_{1/t,\om,r\_t(\om)}\to\om$ as $t\to\infty$. $\quad\Box$


*Remark:* Some of the conditions here can be relaxed. In particular, we do not need $M$ to be a Riemannian manifold or any manifold at all. In particular, it suffices that $M$ be any topological space admitting a finite open cover $\{U\_i\colon i\in[k]\}$ with homeomorphisms $\psi\_i$ of $\ol{U\_i}$ onto compact domains $D\_i\subset\R^{n\_i}$, for each $i\in[k]$.


