Devices like Moto X and Nexus 5X/6P use a sensor hub to achieve this feature, which is a:
microcontroller unit/coprocessor/DSP that helps to integrate data from different sensors and process them. This technology can help off-load these jobs from a product's main central processing unit, thus saving battery consumption and providing a performance improvement.
The Android specifications suggest that the manufacturer implement a sensor hub:
The sensor stack of a device can optionally include a sensor hub, useful to perform some low-level computation at low power while the SoC can be in a suspend mode. For example, step counting or sensor fusion can be performed on those chips. It is also a good place to implement sensor batching, adding hardware FIFOs for the sensor events. See Batching for more information.
How the sensor hub is materialized depends on the architecture. It is sometimes a separate chip, and sometimes included on the same chip as the SoC. Important characteristics of the sensor hub is that it should contain sufficient memory for batching and consume very little power to enable implementation of the low power Android sensors. Some sensor hubs contain a microcontroller for generic computation, and hardware accelerators to enable very low power computation for low power sensors.
So the availability of this feature depends on the hardware of the device: if the manufacturer includes a sensors hub, then the power consumption will be optimized because the central processor isn't involved. Otherwise, the only possibility is to install dedicated apps (see for example the one cited in my comment) that will monitor the accelerometer, resulting, though, in a higher battery drain.