How much space do I need between my tire and brakes to change from 700x23 to 700x25 or 700x28 tires? My concern is that the actual one (700x23) is quite close to my brake (about 3 mm). It's safe for me to buy a 700x25 or 700x28? I would like to have a slightly wider tires.
WRT the photo - I'd be quite confident you can fit a 25mm in there without issue.

A 28mm looks like it would probably fit acceptably, but I doubt a 32 mm would fit.

The best solution here is to take your bike to a Local Bike Shop, and buy your 28mm tyre/tube from there, on the provisio if it doesn't fit on either end you simply swap it for a 25mm.

Second option is to buy the tyre you want, and if it doesn't fit then sell it on ebay/local auction website, but you'll probably take a hit on the value.

Remember, you need to look at chainstay/seatstay clearances at the back, fork clearances at the front, and brake caliper clearances at both ends of the bike.



The other thing that may hold you back on tyre width is rim internal width.  The wider tyres prefer to sit on wider rims.  A 23mm tyre should be on a rim with a width of 13-17mm.  A 28mm tyre wants to be on a rim from 15-21mm.   More info at What is the maximum or minimum tire width I can fit on my bicycle   Though do note these numbers are somewhat fuzzy edges.



Relevant thoughts - wider tyres do make it harder to drop the wheel through the brake pads.  You may need to change your methods, by only inflating the tyre once the wheel is installed in the bike.  Or you may have to look at how to get slack in your brake cable with a quick release or similar.  Not a problem, but it can be frustrating to have to deflate a freshly inflated tyre to get the wheel through the brakes.  More-so if you just used your last cartridge, or have to do it with a minipump (perhaps again!)