At areas where a local increase in traffic density occurs, a temporary tower may be installed. This may be at an uncontrolled airport which may be in class E, or even Class G airspace. By definition, whereas class G is uncontrolled airspace, adding a control tower does require a Notice to Airmen alerting to the change in airspace and the requirement of the control tower at that location. This information will be cited by NOTAM and announced on ATIS and airport advisories.
Temporary towers are typically erected at airshow events, or places where a sudden local increase in traffic has occurred, such as during firefighting operations.
Controllers will be typically FAA controllers, or sometimes retired controllers on a contract basis, or operating with a contractor, in a mobile airport traffic control tower (MATCT). They will be monitoring the common traffic advisory frequency for aircraft that arrive without knowing that a tower is in operation, and in most cases, will quickly advise the arriving aircraft of the tower operation.
It's a pilot (legal) responsibility to become familiar with all aspects of the flight, including checking all NOTAMs. Temporary towers are NOTAM'd prior to going into operation, typically a day or two prior if the advance notice is there, so there's little excuse for blundering into a temporary tower and not knowing its there.
There are towers in Class G airspace, or towers that lack Class D airspace, because the tower or airport lacks the weather reporting capability, which is a requirement for establishing Class D airspace. As the original poster noted in his question, 14 CFR 91.126 covers Class G airspace, and 91.126(d), in the context of Class G airspace, addresses a requirement to establish communication with a control tower prior to 4 nm from the airport.