Yes this is possible with javascript. You need to identify where the conditions can be found on the page and then pass them into a Javascript code, which will inject the attribute value into the cart form.
It is different in every theme but you can start checking from parent file and follow partials from there. You can modify the code and add attributes or custom CSS classes to grab the values
I mention that because to update a LIP after it’s in the cart is a bit more complicated than adding an input to a product form. You will need to either use the ajax api ,or make sure it’s submitted as part of the cart-to-checkout.