this plant appeared where a gully had been graded for the first time to eradicate the Coyote Brush. it’s about five feet tall with a straight smooth trunk and prickly fruit. we are about 2000 feet elevation with a hot dry summer. The plant has not been watered or cared for in any way and it has not been touched by the deer which are very hungry at this time of year. It also seems to be free of insects except for a few aphids and ants. the flowers are yellow and one or two inches long, they look like cucumber/squash/melon flowers. The largest fruit is about five inches long. There has never been a garden on the property but the owners did have pigeons years ago so maybe this was in the bird seed they were fed.
the fruit you also posted is distinctive for Datura quercifolia, Chinese thorn apple, a poisonous plant as are all Daturas. However, the mature flower should be blue or blueish, so I cannot explain the color you mention. I do not know of any Daturas similar to this with yellow flowers. It is native to California and other dry regions in the southwest. The massive thorns make the identification of the fruit rather easy, because most other daturas have much thinner and more numerous spines on the fruit.
Steve Hill, Botanist, SCNPS