I can think couple of methods:
Wrap the text block by bigger element, resize it so that the circle will fit (you will need some serious math skills!) and use cross-browser Raphael library to draw a circle on it.
Based on the width & height of text block, adjust top/bottom padding until the box is square and choose best matching background from different size pre-drawn images.
Sample code (using jQuery) to get the second idea, totally untested:
var images = [300, 200, 100]; // image dimensions from biggest to smallest
var textbox = $('#my-textbox');
var padding = 20; // base padding, choose your own
var w = textbox.width();
var h = textnox.height();
var filler = (w > h ? (w - h) : (h - w)) / 2; // how much extra padding needed?
var pver = w > h ? filler : padding; // padding vertical
var phor = w > h ? padding : filler; // padding horizontal
textbox.css({ paddingTop: pver, paddingBottom: pver,
paddingLeft: phor, paddingRight phor });
$.each(images, function(i, dimension) {
if (dimension < textbox.width())
textbox.css('backgroundImage', 'url(/img/circle_' + dimension + '.png)');
});