JSFiddle - React, Tailwind, and code Playground

HTML

<div id="container">
    <li>Item 1.1</li>
    <li>Item 1.2</li>
    <li>Item 1.3</li>
    <p>Paragraph</p>
    <li>Item 2.1</li>
    <li>Item 2.2</li>
    <p>Para</p>
</div>

JavaScript

$('div#container') // assume you're got it in a container div
.find('p').each(function() { // each p signifies a new group
    $(this).prev('li') // walk back to the preceding li
    .prevUntil('p') // get the set of elements up to the previous p
    .andSelf() // include the current li
    .wrapAll('<ul />'); // wrap the set in a ul
});