I want a function f(x) that uses the constants a, b, M, N and,
Always, a < b
If x < a then f(x) = M
If x > b then f(x) = N
Else, f(x) = x
(x, a, b, M, N all are integers.)

Above image shows a plot created using paint app , where a=3, b=10, M=5, N=9
In words, it is a function that takes an integer. If it is on a certain range, it outputs the same integer. Else, it outputs a pre chosen number according to whether the integer is larger or lower than the specified range.
What will be the equation to get that outputs?
(I want an equation of the function, there can be more than one)
Functions aren't magic and they don't need nor always have special names or formulas. The function you want is:
$f (x)=M $ if $x>a $
$f (x)=N$ if $x <b$
$f (x)=x$ otherwise.
That's it. That IS your function. There is nothing more that needs to be said.