We can calculate this survival probability $P(t) = |\langle \psi | e^{-i \mathcal{H}t} | \psi \rangle|^2$ in two ways. The first corresponds to the so-called Hadamard test, as shown in the figure below,

where $H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}$ is the Hadamard gate and $|\psi \rangle$ is some $n$-qubit state. The probability of measuring the ancillary qubit in state $|0\rangle$ is $\frac{1 + |\langle \psi | e^{-i \mathcal{H}t} | \psi \rangle|^2}{2} \equiv \frac{1 + P(t)}{2}$.
Alternatively, we can avoid the use of an ancillary qubit and the corresponding control of the time evolution provided that we have access to the circuit $U$ such that $U |0\rangle = |\psi \rangle$. In such case, we can simply use the following ancilla-free circuit

By measuring all $n$ qubits, the probability of measuring all qubits in state $|0 \rangle$ (i.e., retrieving the fiducial state) is $|\langle 0 | U^{\dagger} e^{-i \mathcal{H} t} U | 0 \rangle|^2 = | \langle \psi | e^{-i \mathcal{H} t} | \psi \rangle |^2 \equiv P(t)$.
Of course, the remaining question is how to implement the time-evolution operator $e^{-i \mathcal{H}t}$, which is the Hamiltonian Simulation problem mentioned by @MarkusHeinrich. The simplest option is Trotterization, but more sophisticated approaches such as truncated Taylor series with linear combination of unitaries method or qubitization are also available.