Is there a AM radio trasmitter library for raspberry? Like PiFMRDS ? AM travels further and it would get better range on low power RPi trasmitter. Or how could I do that myself? Generate high (~1Mhz) frequency and modulate it according to audio input.
Yes, there is: rpitx
It does AM as well many other modulations: FM, SSB, etc. All thanks to some cunning PWM.
Though, I highly advise you to go and learn a lot more before using it! Really, go grab some books on the basics of radio communication and also check the laws and regulations surrounding it. If you fail to do so you may end up disrupting some critical equipment and get yourself in jail.
Your follow-up questions show a lack of understanding of some basic principles. AM does not travel further. AM is just a type of modulation. What travels further are the carrier waves usually employed with AM modulation: they have a lower frequency than those typically used for FM, and can propagate as ground waves, following the Earth's curvature.
Your intention (getting a better range) also shows that you are unaware of the consequences of transmitting on allocated frequencies, specially with a noisy transmitter. You should have read PiFmRds's Warning and Disclaimer more carefully. Let me quote the most important bits:
In most countries, transmitting radio waves without a state-issued licence specific to the transmission modalities (frequency, power, bandwidth, etc.) is illegal.
Even if you are a licensed amateur radio operator, using PiFmRds to transmit radio waves on ham frequencies without any filtering between the RaspberryPi and an antenna is most probably illegal because the square-wave carrier is very rich in harmonics
All this applies to rpitx as well. These are meant as learning and experimentation tools. You should never transmit further than your room, or better, as PiFmRds advises:
connect a shielded transmission line from the RaspberryPi directly to a radio receiver, so as not to emit radio waves
USB SDR (software defined Radios) exist that will transmit.
However, you have to obtain a legal license to transmit any significant distance. Thus probably defeating the whole benefit of long distance.
You want to use it as a CB or Ham Radio you need to be legally licensed to do so. Take a class and pass a test and pay a fee.
At least with an SDR you can choose alternate frequencies that don't collide with AM or etc transmitters.
Still you need to have a license to do what you want.
It is not the distance, it is the ERP (Effective Radiated Power) and the band that can get you into trouble. By limiting the ERP it has a big effect on distance but on the correct band and atsmopher conditions Amaturer operators have gone thousands of miles. CB across the US with 5 watts power was common in the mid 60's. The best place to increase your distance and not get in trouble is to increase the sensitivity and selectivity of your receiver.
You can purchase commercial communication equipment that will do the job and have a lot more power and range. They will be licenced by the appropriate agency in your country. In the US it is the FCC ()Federal Communications Commission).