In the first case, when the details of the physical process do not matter, you can choose any quantum channel type that can achieve your target average fidelity. Depolarizing channel may be a good choice.
In the second case, you need to know what class of physical processes are acceptable. For example, if you are modeling energy decay, amplitude damping channel may be appropriate. Once you describe the relevant processes as a parametrized quantum channel, then the next step is to identify the parameter values that yield your target average fidelity. In general, this can be done by solving the following equation for parameters $p$ of the channel $\mathcal{E}_p$
$$
\overline F(\mathcal{E}_p) = F\tag1
$$
where $F$ is the target fidelity and $\overline F$ is the average fidelity
$$
\overline F(\mathcal{E}_p) = \int \langle\psi|\mathcal{E}_p(|\psi\rangle\langle\psi|)|\psi\rangle d\psi\tag2
$$
where the integral is with respect to the Haar measure normalized so that $\int d\psi=1$ over the entire state space.
In order to illustrate the procedure, we are going to solve $(1)$ for depolarizing channel $\mathcal{D}_\lambda$
$$
\mathcal{D}_\lambda(\rho) = \lambda\rho + (1 - \lambda) \frac{I}{N}\tag3
$$
where $\lambda$ is a parameter and $\rho$ the input quantum state on a $N$-dimensional Hilbert space. Using $(2)$ and $(3)$ we obtain the following expression for the average fidelity of a depolarizing channel
$$
\begin{align}
\overline F(\mathcal{D}_\lambda) &= \int \langle\psi|\left(\lambda|\psi\rangle\langle\psi| + (1 - \lambda) \frac{I}{N}\right)|\psi\rangle d\psi \\
&= \int \lambda\langle\psi|\psi\rangle\langle\psi|\psi\rangle d\psi + \int (1 - \lambda) \frac{\langle\psi|I|\psi\rangle}{N} d\psi \\
&= \lambda \int d\psi + (1 - \lambda) \frac{1}{N}\int d\psi \\
&= \lambda + (1 - \lambda) \frac{1}{N} \\
&= \frac{N-1}{N}\lambda + \frac{1}{N}
\end{align}
$$
where we used the facts that $\langle\psi|\psi\rangle = 1$ and $\int d\psi=1$. Substituting this into $(1)$, we get
$$
\frac{N-1}{N}\lambda + \frac{1}{N} = F
$$
which we solve to get
$$
\lambda = \frac{FN - 1}{N - 1}.
$$
For example, if you are targeting $98\%$ average fidelity on a qubit ($N = 2$) then you can use depolarizing channel with $\lambda = 0.96$.
You can implement the channel in software using equation $(3)$. For example, in python using numpy arrays to store density matrices
def make_depolarizing_channel(p: float) -> Callable[[np.ndarray], np.ndarray]:
def depolarizing_channel(rho: np.ndarray) -> np.ndarray:
N = rho.shape[0]
return p * rho + (1 - p) * np.eye(N) / N
return depolarizing_channel
where p
corresponds to $\lambda$.