[Sony Xperia XZ1 Compact Questions & Answers] nlra:
While reading through from start to finish both your original post and your updates/replies, it was not originally clear to me that you had installed some app from your IP-PBX vendor that, rather than function as a stand-alone VoIP app, hooks into the "Calling Accounts" feature of the native phone dialer/app. That's fascinating...I did not know there was an Android API that allowed for that! What PBX software are you using?

I just assumed you had tried setting it up originally as a SIP account under the Calling Accounts section of the phone app, as you later described doing in your last update. It's interesting that there is a difference in behavior, but that probably just indicates that the app from your PBX vendor is handling the voice audio differently than the native SIP client is doing.

I have used the native Android SIP client on stock Sony firmware on both Z5 Compact and XZ1 Compact, and I can tell you that it has been riddled with bugs for quite some time. Since I'm in the U.S., our calls are largely G.711 PCMU instead of PCMA. On the Z5c, in Lollipop, making PCMU calls resulted in extremely choppy audio and also slightly slowly, as if every audio sample/frame was being played back with a short gap in between them. I eventually discovered that this could be worked around by changing the "use.voice.path.for.pcm.voip" property in build.prop to "false". I think what this does is no longer offloads audio processing of VoIP calls to the modem baseband, perhaps? It fixed the choppy audio, but I think it may have introduced echo similar to what you are describing (this was a long time ago). Fortunately, this got fixed in Marshmallow on the Z5c & I could leave that prop as the default "true".

Well, after recently trying the SIP client on XZ1c, I can tell you that the exact same PCM SIP audio playback bug from Z5c Lollipop is back!! And unfortunately, it's in both Oreo AND Pie...they never got around to fixing it! If you haven't experienced this, the I can only guess that either it only happens with PCMU, or there is something about the audio source it doesn't like (perhaps the frame size? I think most calls are 20ms frames?) Similarly, if I disable PCM offloading to the "voice path" on XZ1c, the choppiness goes away completely. Since I have only had an opportunity to play with it briefly so far, I haven't tested for echo on the other end yet (just called a number with automated readback). Also, the property name changed on XZ1c, to "vendor.voice.path.for.pcm.voip", and it is set in the build.prop that is located in /vendor and not /system now.

It would be interesting to have you try to also change your "vendor.voice.path.for.pcm.voip" to "false" and then re-run your tests with the native SIP client.

In addition to this annoying problem, the native SIP client on XZ1c on both Oreo and Pie will be unable to talk to your PBX if you also have WiFi Calling configured with your mobile carrier. If you watch the logs on the PBX side, or sniff the WiFi traffic on your phone, you will see that it never even transmits any SIP messages to the PBX IP, even though it claims it's trying. This is a SUPER annoying bug that does NOT happen on the Z5 Compact. On Oreo on the XZ1c, it's even worse because once WiFi Calling gets enabled, the native SIP client will never work again until after the phone is REBOOTED with WiFi Calling turned off (if it boots up with WiFi Calling on, then SIP client is permanently broken again until the next reboot). Finally, if you frequently edit your Calling Account entry for your PBX extension, it will often duplicate itself, disappear from the list entirely, or refuse to let you delete it...again, until you reboot.

It's amazing that all of these bugs managed to sneak past QA and never got fixed! It's like nobody at Sony ever used it!

Finally, I'll just add that the thread you linked to about echo problems was specifically about echo problems during normal phone calls through the mobile carrier, not via SIP, and specifically on certain Z5(c) units. So other than perhaps giving you the idea of tweaking the internal mixer settings, likely not terribly relevant to your issue.