The legislation prohibited a second-trimester procedure known as dilation and evacuation. It is the latest court defeat for a state legislature that has attempted to make it as difficult as possible to have an abortion in Texas, the country’s second-most-populous state.