I tried it in my area. Both with known farmers and strangers.
They all said no, not even for money.
I think nowadays people only do this under the table within the family circle. The possible penalties are too high for that. Basically, it is illegal disposal in the context of house construction.
I would say: yes and no.
Topsoil is actually not waste; according to the Federal Soil Protection Ordinance, it must not be disposed of but must be reused. In some places, you are lucky and come across a thick topsoil layer suitable for farming, which either a farmer or a nearby builder gladly takes for their garden. Completely legal.
If there is a clay layer underneath, it is usually disposed of, but it could also serve as a raw material for a brick or clinker factory.
And if there is still a gravel layer below that, it can of course be reused in other construction projects.
In the above cases, the excavation would not be waste but a product and is therefore not disposed of illegally but reused.
Most excavated material—at least in our region—is qualitatively not suitable or too mixed to be reused. I just wanted to clarify here that not everything a digger scoops out always has to go to the landfill.