The answer depends upon the type of motor. A synchronous motor can usually be driven as an alternator by simply substituting a prime mover for the mechanical load. Things are less clear for an asynchronous/induction motor since it will depend upon whether it is attached to a three-phase supply or not.
If there is a three phase source then the prime mover has to operate at greater than synchronous speed, however its output frequency will be locked to the line frequency, assuming that the source is considerably larger than the motor size.
If there is no external source of power then there will be no output since standalone/isolated induction generators have no means of creating a rotating magnetic field; however it is sometimes possible to use an appropriately sized capacitor bank in combination with the residual magnetism (if any), to use resonance to self-excite at whatever speed the prime mover can provide. A third type called a DFIG is beyond the scope here.
Further to the above, any induction motor is ready to act as a generator if it is connected to the mains. For example if you have a conveyor operating downhill it will start and run as a motor and if you put enough material on the belt going downhill, this can result in the belt driving the motor slightly faster than synchronous speed and the motor will deliver the resultant power into the mains. Another example is a crane hoist, when lowering a large load can generate power into the mains. When you open the contactor or the mains is off the motor will lose voltage and then cannot act as a generator.
If you want an induction motor to self-excite as a generator you need to connect a sufficient capacitor across one or more of the windings then drive the motor at or above synchronous speed and it will self-excite and be ready to deliver power to loads. This method is used for small low cost power generation schemes called micro hydro.