Unfortunately, RigidBody2D is missing a key feature present in RigidBody (3D), constraints.
A workaround could be to always lock your RigidBody2D's position on the X-Axis, although, this may lead to bugs in your physics:
void Update()
{
transform.position = new Vector3(STATIC_X, transform.position.y, transform.position.x);
}
Another option, would be to not use a RigidBody, and attempt to simulate the physics yourself.