Sleeping bags are usually not carried attached to a backpack, no matter if this is a large pack or a small day pack. But if you are in such a situation, no worry, there are various ways to do this.
A sleeping bag is one out of big three elements that people carry on the trail. The other two are a sleeping pad and a tent. So it is rare that you would carry only a sleeping bag.
But there may be situations where you do not need a pad and a tent. This may be the case when you sleep in a refuge and you can manage with a sleeping bag alone.
A sleeping bag is the bulkiest of the stuff you would have, so it may be tricky to attach it to a small daypack. But it is almost always possible. Here I show this in pictures with my own packs.
As you will see, this all depends on the type of your daypack. With some of them it may look impossible to attach a sleeping bag, but just use your imagination, and one or two pieces of cord, and you will manage it.
A day pack without any attachment element
If there are no attachment loops on the front, no daisy chains on the pack, no top lid, no bottom straps, nothing. Even in this case you can manage it.
The picture below shows how I can attach a sleeping bag on the front with one piece of cord. You can use two to make it even more stable.

A daypack with a top lid
There are many daypacks with a top lid. The lid does not have to be floating type, it will still have two straps with buckles that attach it to the front of the pack.
The picture below shows such an example. This is a very small day pack with a lid, and I have chosen a large sleeping bag for demonstration. The pack is full, but it is still very possible to put the sleeping bag on the pack and keep it in place with the lid.

Below I demonstrate this in my another small day pack with a lid. So the lid straps are again long enough to keep this bulky sleeping bag in place.

A panel loading type zippered day pack with dual compression straps on the sides
In this case there is no top lid, but you can still be able to attach a sleeping bag. One example is this Osprey Stratos 24 in the picture below. So here you can use one extra piece of cord and attach the sleeping bag on the front.
For this you attach the cord to the side compression straps, see how this looks, the bag is very secure in this setup:

A daypack without dual side straps
If you have only one compression strap on each side, and in addition the pack has a handle on the top, use a piece of cord and make a sort of net with it.
This means attach it to the side straps and to the top grab handle, and then compress the sleeping bag on the front of the pack with this. In the picture below I again use my Osprey Stratos 24 pack that has a top handle, and I use only the two lower side straps. The cord makes an inverted-T configuration.

A day pack with two bottom loops & a carry handle
So here you use dual bottom loops, some packs have them two on the bottom/sides, and a carry handle on the top. So use one piece of cord and attach it to these three points and compress the sleeping bag on the front of the pack as in the picture:

In this case the cord creates an inverted V shape on the front and the sleeping bag is secured in place.
A day pack with bottom straps
Not many day packs will have bottom straps, but this all depends on what one consider as a day pack. I sometimes use my 50 liters pack for a day tour.
Such bottom straps are usually used for less bulky items but they can be used for a sleeping bag as well. My old Deuter Futura pack has bottom straps, and they are long enough that I can attach the sleeping bag as in the picture.

Day packs with front loops or daisy chains
I was showing 4 of my daypacks, so I would not need to buy one for the purpose described here. But if you do not have a daypack and want one with attachment features, there are small daypacks that come equipped with two parallel daisy chains on the front. One example is in the picture below left, this is the Teton Sports Circue 1600 pack.
The same brand has yet another daypack with four attachment loops, the Teton Sports Pursuit 2000 pack, it is on the right. Both packs are incredibly affordable.

Summary
So I hope you realize that there are many ways of attaching a sleeping bag to a daypack. The pictures above show how this can be done in some situations, but this all depends on the daypack you use. Some of these ways may work for you, but if this is not exactly so, you can always combine some of them.
On the other hand, expensive sleeping bags are with such a price partly because they are in incredibly compact. It is far easier to attach them to a pack. This is why, for the trail, it may be better to buy an expensive bag rather than a cheap one, but follow the link to read more.
If you have additional questions please do not hesitate to ask, there is a comment box below. Thank you for reading and have a nice day.