An elliptical lift distribution is optimal in terms of induced drag. It can be achieved by an elliptical planform (with a straight span and un-cambered airfoils and no twist), or by twisting a more complex wing.
An elliptical lift distribution is not optimal in terms of wing weight. It may also not be optimal in terms of handling qualities, tip stall, flutter, aileron reversal, etc.
Modern composite wings also flex a tremendous amount in flight some of this can be planned for, but you still need to design a wing that operates well at off-design conditions, not just at a narrow design point.
The theoretical elliptical wing is un-swept. To fly at transonic speeds of an airliner, you must have a swept wing.
So, with all that, a traditional elliptical wing is not optimal for an airliner. There are many good reasons not to use one.
That said, composites would allow more swoopy curves on a wing -- while wings still appear to be mostly straight. Even if they aren't elliptical, why not use more compound curves?
There are still good reasons to prefer straight lines. Airliner wings have control surfaces and high lift devices all over them -- slats, flaps, ailerons, and spoilers. All of these are mechanisms that need to operate without binding. To do so, it is best to make the hinge line straight -- or to design with aligned tracks and linkages.
Even with a straight hinge line, the 787 breaks the control surfaces into many segments -- to accommodate the flex of the wing.