This is what Custom Orientations are for.
In the Transform Orientation dropdown, there's a '+' sign, which will create an orientation from your current selection. You have the options in the operator to name the orientation, use the orientation immediately after creation, and/or overwrite the previous orientation, to avoid clutter.
If you create an orientation from an edge, or 2 vertices, then the Y of the new space runs along the edge. (I believe the Z is in the mean direction of the vertex-normals, and X is at right-angles to Y and Z)
If you create an orientation from a face or 3 vertices, then Z is the normal of the defined plane, (I think X and Y are the tangent and cotangent, and it's not easy to know which edges determine those, as a user)
So for example, to flatten to a plane normal to an edge and at one end of it, it could be:
- Set Pivot to 'Active Element'
- Select the edge and create an orientation from it
- Select the vertices to be flattened, making the one at the end of the edge active
- SY0 scale the vertices to 0 about the active vertex, in the direction of the edge.
In your case, you could also create an orientation from the opposite face, (the one you want to align to), and with the same selection of vertices, SZ0