There is variety of loudspeakers on the market that have built-in microphone so that they can produce sound and perceive it at the same time (and do it surprisingly well).
How they managed to overcome audio feedback problems?
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It only takes a minute to sign up.Sign up to join this community
By using Acoustic Echo Cancellation. Since the signal that goes to the speaker is known you can subtract it out at the microphone, provided you know the exact transfer function from speaker to microphone. The determination of the transfer function is typically done through an adaptive filter. Similar techniques can be used to reduce reflections, reverberation and echoes from the room.
In addition, there are often multiple microphones using beam forming. The beams can be steered so that the pickup from the speaker is minimized (basically steering a null in the polar pattern to the speaker) and it can also be used to maximize pickup of the desired sound.
All of these things are really difficult, complicated and hard to get right. Cancellation and adaption often create artifacts that significantly reduce speech intelligibility. The quality of commercial implementation varies all over the place. In my name brand laptop, it's so bad that it's worse than useless and I simply turned it off. I have tried multiple USB speakerphones and also found a huge variability in quality. Finally I found one that actually works :-) but product recommendation are out of scope of this site. Let's just say that the one pictured is fairly decent.
I agree with Hilmar's answer as far as signal processing is concerned. The problem is that bad acoustic design can hardly be compensated for by signal processing. My point is that it is very important to have a very good acoustic design that makes sure that the speaker and the microphone are vibrationally insulated as far as possible. Mechanical vibrations caused by the speaker and fed into the microphone are often non-linearly related to the source signal, and consequently, their cancellation by signal processing methods is very difficult. This is one important reason why they must be avoided as far as possible by a good design. Any residual echoes must be suppressed by signal processing methods as described in Hilmar's answer.