There are various ways in which this can be done: native Simulink blocks, Stateflow charts, MATLAB Function, etc...
Here's how I would do it with a MATLAB Function block:
function vcons = piecewise_fcn(x)
% Define Vref, kx, and x_stop
if kx*(x_stop - x) >= Vref
vcons = Vref;
elseif kx*(x_stop - x) <= -Vref
vcons = -Vref;
else
vcons = kx*(x_stop - x);
end