I am looking for such a function for plotting a figure like in the picture in Python.
Many thanks!

I am looking for such a function for plotting a figure like in the picture in Python.
Many thanks!

You want to craft $f(x)$ so that $f''(x)$ is
Also, it appears that you want $f(0) = 0.$
Let $g(x) = f''(x)$.
It is easy to construct $g(x) = 1 - x.$
Then, integrating twice, you have that
$$ f(x) = \frac{x^2}{2} - \frac{x^3}{6}.\tag1 $$
Edit
If it is also desired that $f(1)$ take on a certain value $A$, note that in (1) above, you can add the term $rx^1$ to $f(x),$ where $r$ can be any scalar. Such an added term will have no effect on either the second derivative of $f$, or the constraint that $f(0) = 0.$
Edit
In retrospect, given your question's preCalculus tag, I question how appropriate my answer is. However, I was introduced to the concept of convex/concave functions as part of a Calculus class, and I do not know how to approach the problem in any other way.
python is able to concatenate functions, right, so why not use two functions, one for the each intervall?