mathematics – How to construct a matrix with the following mapping

How would I create a matrix that maps coordinates like so:

Near plane

x: (-3,3) -> (-1,1)
y: (-6,2) -> (-1,1)
z: 2 -> -1

Far plane

x: (-4,4) -> (-1,1)
y: (-4,4) -> (-1,1)
z: 0 -> 1

Visual
coordinates

Result:
result

My current solution is a transformation in a vertex shader like below, but if it’s possible to use a matrix I can keep my shaders as is.

vec4 special_projection(vec4 p){
  float ty = 0.25 * p.z;
  float tx = 0.25 * p.x;
  float xz = (tx / 3.0) * (p.z / 2.0);
  float x = tx + xz;
  float y = 0.25 * p.y + ty;
  float z = -0.5 * p.z;
  return vec4(x,y,z,1);
}