This can be done with the workbench engine, if you don't need motion blur as shown in your example image and the colors don't have to be 100% accurate. For accurate results you will have to create a material for Cycles and Eevee.
Approach 1: Workbench Engine
- Switch to the Workbench engine
- Enable MatCap as material and select the normal map matcap.
- Enable Transparent for the Film
- Set the View Transform to Standard
Approach 2: Material for Cycles and Eevee
If you need accurate results, then you have to create a material for Cycles and Eevee that transforms the object's normals into camera space and uses them as a color for the object. This can be accomplished by transforming the Normal output of the Geometry node, which gives the normal in world space, into camera space with the Vector Transform node. In order to get the proper colors you will have to adjust the output though, since the camera normals have the following ranges:
$$ x: [-1.0, 1.0]\\ y: [-1.0, 1.0]\\z:[-1.0,0.0]$$
Colors have to be in a $[0.0,1.0]$ range, therefore the vector has to be multiplied with $[0.5, 0.5, -0.5]$ componentwise and then shifted by $[0.5, 0.5, 0.5]$. The node setup is depicted in the following image. Note that the emission shader is only visible from the camera and therefore doesn't impact other objects in the scene.
Make sure to either save the result as OpenEXR or set the View Transform to Raw to get the exact pixel values.
The result produced with the second approach is more accurate, since it calculates the normals properly instead of performing a look up in the matcap bitmap. The material doesn't have to be assigned to every object individually if you use material override as @RobinBetts mentioned.