Using a digital id to sign and encrypt messages in Outlook has been working fine. However, is there a way to do this in general using web mail via a web ui? I have both GMail and email from an ISP in mind here.
I believe this firefox extension may do what you require:
Encrypt the Cloud looks promising. It's an extension for Chrome and you are able to encrypt any text box in a browser. It is an open-source project ("so you can be sure it's doing nothing evil" the developer said) and using AES for the encryption, but you have to share the
key with the other side.
One safe way of sharing a secret is to do it over a Video Call (if you are not face to face of course) by writing it on a paper, showing it to the camera and burning the paper afterwards. The video call should use a p2p connection and not through their servers though, in order to be confident that they are not able to record the videos. If someone is eavesdropping your network is much harder to extract a video stream than a usual chat.
I don't think there would be a way to do this "in general", that is to say, for any given webmail client. I think the webmail client would need to specifically support it, because you'd have to somehow put base64-encoded (or some other encoding) encrypted data into the webmail client... And even then, the webmail client would not set the MIME-type to the proper value for S/MIME unless it specifically understood how to do so. You'd just end up sending a Base64-encoded chunk of data, which wouldn't automatically be detected by the receiver's email client.
Perhaps you should consider using GPG (or PGP) instead, as GPG could put the signature right at the bottom of the message (instead of as a MIME attachment as S/MIME does). I switched away from GPG because so few people use it, however I also use Thunderbird instead of a webmail client most of the time.