I) One problem is that the momentum operator $\hat{p}$ is an unbounded operator, which means that it is only defined on a domain $D(\hat{p}) \subsetneq {\cal H}$ of the Hilbert space ${\cal H}=L^2(\mathbb{R})$.
When we apply the differentiation operator $\hat{p}=\frac{\hbar}{i}\frac{d}{dx}$ to OP's wave function
$$ \psi(x)~=~A(a-x)\theta(a-|x|), \qquad A~>~0, \tag{1}$$
we get a term proportional to a distribution, cf. Stephen Powell's answer, so that the image $\hat{p}\psi\notin{\cal H}$ is outside the Hilbert space ${\cal H}=L^2(\mathbb{R})$ of square integrable functions. Stated a bit more precise, the issue is that OP's wave function $\psi \notin D(\hat{p}) $ is not in the domain $D(\hat{p})$ of the momentum operator $\hat{p}$, so that the calculation does not make mathematical sense, cf. answer & below comments by Valter Moretti.
II) Nevertheless, apart from standard arguments about expectation values of operators, we can perform various non-rigorous heuristic explicit calculations that indicate that the average momentum $\langle p \rangle$ should be interpreted as zero:
$$\begin{align} \langle p \rangle
~=~&\frac{\hbar }{i}\int_{\mathbb{R}} \! dx ~\psi(x)\psi^{\prime}(x)\cr
~=~&\frac{\hbar }{2i}\int_{\mathbb{R}} \! dx \frac{d}{dx}\psi(x)^2\cr
~=~&\frac{\hbar }{2i}\left[\psi(x)^2 \right]^{x=\infty}_{x=-\infty}\cr
~=~&0,\end{align} \tag{2} $$
or
$$\begin{align} \langle p \rangle
~=~~&\frac{\hbar }{i}\int_{\mathbb{R}} \! dx ~\psi(x)\psi^{\prime}(x)\cr
~\stackrel{(1)}{=}~~&\frac{\hbar A^2}{i}\int_{\mathbb{R}} \! dx~ (a-x)\theta(a-|x|)\frac{d}{dx}\left\{ (a-x)\theta(a-|x|)\right\}\cr
~\stackrel{\begin{matrix}\text{Leibniz'}\\ \text{rule}\end{matrix}}{=}&
\frac{\hbar A^2}{i}\int_{\mathbb{R}} \! dx~ (a-x)\theta(a-|x|)\cr
&\left\{-\theta(a-|x|) - (a-x){\rm sgn}(x) \delta(a-|x|) \right\} \cr
~=~~&\frac{\hbar A^2}{i}\left\{\int_{-a}^a \! dx~ (x-a)
- \sum_{x=\pm a} (a-x)^2\theta(a-|x|){\rm sgn}(x) \right\} \cr
~=~~&\frac{\hbar A^2}{i}\left\{ -2a^2+4a^2 \theta(0)-0\right\}\cr
~=~~&0. \end{align} \tag{3}$$
In the last equality we assigned the value $\theta(0)=\frac{1}{2}$ to the Heaviside step function $\theta$, cf. e.g. this Phys.SE post.
III) It becomes more ill-defined to try to calculate
$$\langle p^2 \rangle~=~\left(\frac{\hbar }{i}\right)^2\int_{\mathbb{R}} \! dx ~\psi^{\prime}(x)^2~=~\infty,\tag{4}$$
partly because a square of the Dirac delta distribution is ill-defined, cf. e.g. this Phys.SE post. At least the value $\infty$ in eq. (4) doesn't conflict with the Heisenberg uncertainty relations!