Not 100% certain what you have to start with or what you really want to end up with, but here is a technique that can give you a soft shadow behind text. Basically, you do the following:
- create a spare piece of canvas big enough for your text
- write your text on the canvas
- blur it to soften it
- paste that onto the original image
- write the sharp text on top
There are a million variations, with different type of blur, different font sizes, different under-colours (shadow colours) and different ways of pasting/compositing the blurred text onto the original. But if you take the code below as a starting point you can experiment till you are happy.
#!/usr/bin/env python3
# See also: https://legacy.imagemagick.org/Usage/fonts/#soft_shadow
from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageChops
# Open background image and work out centre
bg = Image.open('bg.png').convert('RGB')
x = bg.width//2
y = bg.height//2
# The text we want to add
text = "StackOverflow"
# Create font
font = ImageFont.truetype('/System/Library/Fonts/MarkerFelt.ttc', 60)
# Create piece of canvas to draw text on and blur
blurred = Image.new('RGBA', bg.size)
draw = ImageDraw.Draw(blurred)
draw.text(xy=(x,y), text=text, fill='cyan', font=font, anchor='mm')
blurred = blurred.filter(ImageFilter.BoxBlur(7))
# Paste soft text onto background
bg.paste(blurred,blurred)
# Draw on sharp text
draw = ImageDraw.Draw(bg)
draw.text(xy=(x,y), text=text, fill='navy', font=font, anchor='mm')
bg.save('result.png')
Original image

Result image
