Back in DF version 0.23.130.23a (which had less compiler optimization, making the disassembly much easier to read), this is how farm plots worked:
1. Base yield is set to 1.
2. If the farm plot is at least 25% fertilized, increase yield by rand(2) (a random number from 0 to 1).
3. If the farm plot is at least 50% fertilized, increase yield by rand(2).
4. If the farm plot is at least 75% fertilized, increase yield by rand(2).
5. If the farm plot is 100% fertilized, increase yield by rand(2).
6. If rand(5) (a random number from 0 to 4) is less than the Planting skill for the seed (the Farmer's skill level when the seed was planted, capped at 20 = Legendary+5), increase yield by rand(2).
7. If rand(10) is less than the Planting skill for the seed, increase yield by rand(2).
8. If rand(15) is less than the Planting skill for the seed, increase yield by rand(2).
9. If rand(20) is less than the Planting skill for the seed, increase yield by rand(2).
10. If rand(25) is less than the Planting skill for the seed (again, capped at 20) and rand(3) is equal to 0, increase yield by rand(2).
The end result is that a Legendary+5 farmer planting in a 100% fertilized field can get yields of up to 10, but that's the absolute maximum (so yields will probably average at around 4-5). Also, fertilization only matters the instant the seed matures into a stack of plants, so you don't actually need to fertilize the plot until after you've planted the seeds (and indeed, it's better to plant the seeds first and then apply the fertilizer while you wait for the seeds to grow so you can increase your chances of planting and harvesting a second set of crops before the season changes and the fertilizer wears off).
Taking a brief look at a disassembly of said logic in 0.34.11, it looks like it hasn't changed in the past 5+ years, though I can't be sure that all of the random number ranges are the same (because the compiler optimizes them away and turns them into inlined multiplications and shifts).