You can do whatever you want, which is the beauty of Jazz. It's more a matter of whether other people will still call what you're doing Jazz.
I've implied a flat 9 (which I generally consider an energized root rather than a lowered second) in a piece with a simple, whole-note melody within Db maj of Db-C-D-Db. This works to my ear (and is followed by G maj, E maj, Db maj, to give you some context).
It is going to have more 'dissonance', but this can work fine depending on how you do it. Playing those notes in different octaves and/or with different instruments whose timbres are distinctively different are two tricks. Avoiding playing the two notes together or moving among them quickly are two more. On the other hand, sometimes the extra tension among notes is something we want. Consider Jerry Lee Lewis's right-hand clusters in some of his soloing, or the tense, stabbing strings portion of Stravinsky's Rite of Spring (Dance of the Young Maidens).
Digressing a little, I think that a lot of Westerners, upon hearing a raised root, expect a minor 7th, but you can get a nice and unusual mood from having both a leading tone above and below, and providing the same for the 5th can work well with this, too. For example, C-C#-E-F#-G-G#-B-C .
Here's an example of this sort of thing, and note that if we were analyzing as Jazz we'd probably imagine a 9th which contains the elements you mentioned:
There are major 7ths in this piece, though not all of the 7ths are major. To feel how the notes play together, if you have the means you may want to run this piece through delay or reverb so that the +1 and -1 rub together.
Not all music picks either a major or minor 7th, 3rd, or raised 4th over a "perfect 4th" and sticks to it, and in fact I prefer to avoid this scale-derived nomenclature unless communicating with others who rely on it, as it engenders a mindset which encourages such adherences. To me it's more freeing to think in terms of scale degree while remembering the relative resonances between degrees. Some Jazz traditionalists seem to frown upon this and prefer the prevailing nomenclature.
One more I happened to notice after my last edit:
Very nicely expresses the idea of those two notes, at least one way of using them. Start at 4:30.