I've found a solution using the <wbr>
element and a little bit of JavaScript.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr
Here is the code :
let element = document.getElementById("paragraph"); // Get the element
let width = element.offsetWidth; // Get the current width of the element
element.style.width = width - 1 + "px"; // Set the new width to be the original width minus 1px
#paragraph {
white-space: nowrap;
width: fit-content
}
<p id="paragraph">
one two<wbr /> three four
</p>