Yes, it is possible to change direct current into alternating current.
A power inverter, or inverter, is an electronic device or circuitry that changes direct current (DC) to alternating current (AC). The input voltage, output voltage and frequency, and overall power handling depend on the design of the specific device or circuitry.
A transistor also convert DC supply to AC output.
When a combo of transistors switched alternatively by (gate or base signals) it would act as an inverter by switching power from battery. The best way to convert DC into AC is the help of and alternator and the frequency of AC output depends on the speed of the alternator