In Flash S02E20, the Speed Force takes the faces of Barry's friends and family to communicate with him while he is in the Speed Force. Is the Speed Force of the comics ever sentient like this? Does it ever communicate with Speedsters directly by talking to them, or trapping them in a different reality like it does in this episode? Or is this something done purely for the TV show?
This question is not exactly easy to answer.
The Speed Force was not initially part of The Flash comics, it was a later explanation that was retconned as an explanation for virtually all DC speedsters' powers.
That said, there have been many, many continuities of DC within the comics (as this question specifically limits itself to). Most specifically, the Speed Force is a thing in both the New 52 and the pre-New 52 comics, but this does not necessarily mean that something true about the Speed Force in one of those continuities applies to both.
There are countless references to speedsters assigning the Speed Force some form of agency. Some have said things like, "The Speed Force wants me back in" or similar phrases. Still, at other times everyone treats it as they treat any other 'force' - as a natural process with no agency of its own.
It's honestly hard to say if the Speed Force has a personality, desires, or feelings in any of the comics. There, to my knowledge, has never been a character who served as a 'voice' for the Speed Force, or any time when the Speed Force explicitly acted as a person (or person-like entity). Even on the TV show, it is possible that the Speed Force doesn't actually have agency - the whole 'talking to the Speed Force' thing could be retconned in the future as Barry sorting through his own mixed emotions. The Speed Force has, on occasion, trapped speedsters within it, but in those cases it was treated as being a dimension which was difficult to access and easy to become lost within, not as a sentient being which sought to capture and ensnare speedsters.
Thus, as far as I know, the answer to your question is, No, the Speed Force is not sapient or sentient in the comics. But it would only take a single panel of a single issue to change this in the future.
The answer is....no and yes. The Speed Force is actually Barry Allen. He generates it and is it, making it sentient since Barry is sentient, but it, in itself, is not. It is sorta like asking, "Is your foot sentient?" Well, in the sense that it is a part of me it is, but by itself, no. Further, when Barry runs "into" the Speed Force he doesn't experience it as a part of himself, even when he is "merged" with it.
While there is a special connection with the Speed Force that Barry has, for all intents it essentially doesn't exist and all speedsters are treated the same with regards to it. Likewise, while the Speed Force can be considered a part of Barry, it's not an organic part and it acts more like a Natural Phenomena than anything with it's own laws and rules. Hypothetically, Barry should be able to over-ride anything to do with the Speed Force, but we've never seen him do it.
Another issue is that even though the Speed Force is Barry it doesn't act like it is Barry when you consider enemies are capable of using the Speed Force, but this can be resolved by the idea that the Speed Force exists in all times and universes and is near equivalent to "The Source" meaning that it could be that the Speed Force is a hyper enlightened Over soul version of Barry Allen rather than the specific Barry Allen we see and if that is the case, then you could argue that the enemies of Barry Allen are useful or have purpose in the grand scheme and thus the Speed Force allows access.
So final answer... A little of Column A. A little from Column B. And it depends on how you look at it.
Barry Allen generates the Speed Force.
Max Mercury discovered that it is Barry Allen himself who generates the Speed Force with every step that he runs. When he was struck by the bolt of lightning that gave him his powers, the Speed Force was created and echoed through time and every dimension. By running, Barry generates a kinetic wall between the present and the time barrier that manifests as electrical energy that touches every part of reality and contains the knowledge of every place and every time.
Barry was "The First Speedster", even though there were speedsters before him, like Jay Garrick and Max Mercury. He caused the speed force to come into being.